Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
SkyAPM
SkyAPM-php-sdk
提交
1b266ef0
S
SkyAPM-php-sdk
项目概览
SkyAPM
/
SkyAPM-php-sdk
通知
14
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyAPM-php-sdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
1b266ef0
编写于
6月 22, 2019
作者:
H
heyanlong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add sock
上级
fdf2a1c3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
53 addition
and
126 deletion
+53
-126
config.m4
config.m4
+2
-111
skywalking.c
skywalking.c
+51
-15
未找到文件。
config.m4
浏览文件 @
1b266ef0
dnl $Id$
dnl config.m4 for extension skywalking
dnl Comments in this file start with the string 'dnl'.
dnl Remove where necessary. This file will not work
dnl without editing.
dnl If your extension references something external, use with:
dnl PHP_ARG_WITH(skywalking, for skywalking support,
dnl Make sure that the comment is aligned:
dnl [ --with-skywalking Include skywalking support])
dnl Otherwise use enable:
dnl PHP_ARG_ENABLE(skywalking, whether to enable skywalking support,
dnl Make sure that the comment is aligned:
dnl [ --enable-skywalking Enable skywalking support])
PHP_ARG_ENABLE(skywalking, whether to enable skywalking support,
[ --enable-skywalking Enable skywalking support])
PHP_ARG_WITH(libgrpc, for libgrpc support,
[ --with-libgrpc[=DIR] Include libxyz support])
if test -z "$PHP_DEBUG"; then
AC_ARG_ENABLE(debug,
[ --enable-debug compile with debugging system],
[PHP_DEBUG=$enableval], [PHP_DEBUG=no]
)
fi
[ --enable-skywalking Enable skywalking support])
if test "$PHP_SKYWALKING" != "no"; then
PHP_REQUIRE_CXX()
dnl search grpc
SEARCH_GRPC_PATH="/usr/local /usr"
SEARCH_GRPC_FOR="/include/grpc/grpc.h"
if test -r $PHP_LIBGRPC/$SEARCH_GRPC_FOR; then
LIBGRPC_DIR=$PHP_LIBGRPC
else
AC_MSG_CHECKING([for libgrpc files in default path])
for i in $SEARCH_GRPC_PATH ; do
if test -r $i/$SEARCH_GRPC_FOR; then
LIBGRPC_DIR=$i
AC_MSG_RESULT(found in $i)
fi
done
fi
if test -z "$LIBGRPC_DIR"; then
AC_MSG_RESULT([not found])
AC_MSG_ERROR([Please install libgrpc - See https://github.com/grpc/grpc])
fi
PHP_ADD_INCLUDE($LIBGRPC_DIR/include)
PHP_ADD_INCLUDE(src/report/deps/boost)
PHP_CHECK_LIBRARY(grpc, grpc_channel_destroy,
[
PHP_ADD_LIBRARY_WITH_PATH(grpc, $LIBGRPC_DIR/lib, LIBGRPC_SHARED_LIBADD)
AC_DEFINE(HAVE_LIBGRPCLIB,1,[ ])
],[
AC_MSG_ERROR([wrong libgrpc lib version or lib not found])
],[
-L$LIBGRPC_DIR/lib
])
PHP_SUBST(LIBGRPC_SHARED_LIBADD)
dnl SKYWALKING_SHARED_LIBADD="-lpthread $SKYWALKING_SHARED_LIBADD"
dnl AC_MSG_ERROR($SKYWALKING_SHARED_LIBADD)
dnl KYWALKING_LIBS=`pkg-config --cflags --libs protobuf grpc++ grpc`
dnl KYWALKING_LIBS+=" -Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed -ldl "
AC_OUTPUT_COMMANDS(
protoc -I ./src/protocol-6 --cpp_out=./src/grpc ./src/protocol-6/common/*.proto
protoc -I ./src/protocol-6 --cpp_out=./src/grpc ./src/protocol-6/register/*.proto
protoc -I ./src/protocol-6 --cpp_out=./src/grpc ./src/protocol-6/language-agent-v2/*.proto
protoc -I ./src/protocol-6 --grpc_out=./src/grpc --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` ./src/protocol-6/common/*.proto
protoc -I ./src/protocol-6 --grpc_out=./src/grpc --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` ./src/protocol-6/register/*.proto
protoc -I ./src/protocol-6 --grpc_out=./src/grpc --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` ./src/protocol-6/language-agent-v2/*.proto
)
AC_OUTPUT_COMMANDS(
mv src/grpc/common/common.grpc.pb.cc src/grpc/common/common-grpc.pb.cc
mv src/grpc/register/Register.grpc.pb.cc src/grpc/register/Register-grpc.pb.cc
mv src/grpc/language-agent-v2/trace.grpc.pb.cc src/grpc/language-agent-v2/trace-grpc.pb.cc
mv src/grpc/register/InstancePing.grpc.pb.cc src/grpc/register/InstancePing-grpc.pb.cc
mv src/grpc/common/trace-common.grpc.pb.cc src/grpc/common/trace-common-grpc.pb.cc
)
dnl PHP_EVAL_LIBLINE($KYWALKING_LIBS, SKYWALKING_SHARED_LIBADD)
PHP_ADD_LIBRARY(stdc++, 1, SKYWALKING_SHARED_LIBADD)
PHP_ADD_BUILD_DIR($ext_builddir/src/grpc)
PHP_ADD_INCLUDE("src/grpc")
PHP_ADD_INCLUDE("src")
PHP_SUBST(SKYWALKING_SHARED_LIBADD)
PHP_NEW_EXTENSION(skywalking, \
skywalking.c \
src/greeter_client.cc \
src/decode.c \
src/encode.c \
src/grpc/common/common-grpc.pb.cc \
src/grpc/common/common.pb.cc \
src/grpc/register/Register-grpc.pb.cc \
src/grpc/register/Register.pb.cc \
src/grpc/language-agent-v2/trace-grpc.pb.cc \
src/grpc/language-agent-v2/trace.pb.cc \
src/grpc/register/InstancePing-grpc.pb.cc \
src/grpc/register/InstancePing.pb.cc \
src/grpc/common/trace-common-grpc.pb.cc \
src/grpc/common/trace-common.pb.cc \
, $ext_shared,, -Wall -Werror -std=c++11)
, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
fi
skywalking.c
浏览文件 @
1b266ef0
...
...
@@ -51,12 +51,9 @@
#include <fcntl.h>
#include <dirent.h>
#include "b64.h"
extern
int
serviceRegister
(
char
*
grpc_server
,
char
*
code
);
#include <sys/un.h>
extern
int
serviceInstanceRegister
(
char
*
grpc_server
,
int
appId
,
long
registertime
,
char
*
osname
,
char
*
hostname
,
int
processno
,
char
*
ipv4s
);
#include "b64.h"
/* If you declare any globals in php_skywalking.h uncomment this:
*/
...
...
@@ -64,11 +61,12 @@ ZEND_DECLARE_MODULE_GLOBALS(skywalking)
/* True global resources - no need for thread safety here */
static
int
le_skywalking
;
static
int
application_instance
=
0
;
static
int
application_id
=
0
;
static
int
application_instance
=
-
10000
0
;
static
int
application_id
=
-
10000
0
;
static
int
sky_close
=
0
;
static
int
sky_increment_id
=
0
;
char
*
uuid
=
NULL
;
const
char
*
sock_path
=
"/tmp/sky_agent.sock"
;
/* {{{ PHP_INI
*/
...
...
@@ -920,6 +918,47 @@ static void module_init() {
}
}
static
int
sky_register
()
{
if
(
application_id
==
-
100000
||
application_instance
==
-
100000
)
{
struct
sockaddr_un
un
;
un
.
sun_family
=
AF_UNIX
;
strcpy
(
un
.
sun_path
,
sock_path
);
int
fd
;
char
message
[
4096
];
char
return_message
[
4096
];
fd
=
socket
(
AF_UNIX
,
SOCK_STREAM
,
0
);
if
(
fd
>=
0
)
{
int
conn
=
connect
(
fd
,
(
struct
sockaddr
*
)
&
un
,
sizeof
(
un
));
if
(
conn
>=
0
)
{
bzero
(
message
,
sizeof
(
message
));
sprintf
(
message
,
"0{
\"
app_code
\"
:
\"
%s
\"
,
\"
pid
\"
:%d}
\n
"
,
SKYWALKING_G
(
app_code
),
getppid
());
write
(
fd
,
message
,
strlen
(
message
));
bzero
(
return_message
,
sizeof
(
return_message
));
read
(
fd
,
return_message
,
sizeof
(
return_message
));
application_id
=
atoi
(
return_message
);
if
(
application_id
!=
-
100000
)
{
bzero
(
message
,
sizeof
(
message
));
sprintf
(
message
,
"1{
\"
application_id
\"
:
\"
%d
\"
,
\"
pid
\"
:%d}
\n
"
,
application_id
,
getppid
());
write
(
fd
,
message
,
strlen
(
message
));
bzero
(
return_message
,
sizeof
(
return_message
));
read
(
fd
,
return_message
,
sizeof
(
return_message
));
application_instance
=
atoi
(
return_message
);
}
}
close
(
fd
);
}
}
return
0
;
}
/* {{{ PHP_MINIT_FUNCTION
*/
...
...
@@ -931,15 +970,10 @@ PHP_MINIT_FUNCTION (skywalking) {
*/
if
(
SKYWALKING_G
(
enable
))
{
if
(
strcasecmp
(
"cli"
,
sapi_module
.
name
)
==
0
)
{
sky_close
=
1
;
}
else
{
module_init
();
return
SUCCESS
;
}
if
(
sky_close
==
1
)
{
return
SUCCESS
;
}
// set_sampling_rate(SKY_G(global_sampling_rate));
// bind curl
zend_function
*
old_function
;
if
((
old_function
=
zend_hash_str_find_ptr
(
CG
(
function_table
),
"curl_exec"
,
sizeof
(
"curl_exec"
)
-
1
))
!=
NULL
)
{
orig_curl_exec
=
old_function
->
internal_function
.
handler
;
...
...
@@ -982,7 +1016,9 @@ PHP_RINIT_FUNCTION(skywalking)
ZEND_TSRMLS_CACHE_UPDATE
();
#endif
if
(
SKYWALKING_G
(
enable
))
{
if
(
sky_close
==
1
)
{
sky_register
();
if
(
application_id
==
-
100000
||
application_instance
==
-
100000
)
{
sky_close
=
1
;
return
SUCCESS
;
}
sky_increment_id
++
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录