Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
SkyAPM
SkyAPM-php-sdk
提交
75270060
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,发现更多精彩内容 >>
提交
75270060
编写于
7月 22, 2019
作者:
w60514603
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
支持mysqli扩展的监控;./configure --enable-mysqli=yes来启用对mysqli的监控支持
上级
79a72ee7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
58 addition
and
0 deletion
+58
-0
config.m4
config.m4
+7
-0
skywalking.c
skywalking.c
+51
-0
未找到文件。
config.m4
浏览文件 @
75270060
PHP_ARG_ENABLE(skywalking, whether to enable skywalking support,
[ --enable-skywalking Enable skywalking support])
PHP_ARG_ENABLE(mysqli, whether to enable mysqli support,
[ --enable-mysqli Enable mysqli support], no, no)
if test "$PHP_SKYWALKING" != "no"; then
PHP_NEW_EXTENSION(skywalking, \
skywalking.c \
...
...
@@ -8,3 +11,7 @@ if test "$PHP_SKYWALKING" != "no"; then
encode.c \
, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
fi
if test "$PHP_MYSQLI" != "no"; then
AC_DEFINE(SKYWALKING_ENABLED_MYSQLI, 1, [Enable skywalking support])
fi
skywalking.c
浏览文件 @
75270060
...
...
@@ -249,6 +249,10 @@ ZEND_API void sky_execute_internal(zend_execute_data *execute_data, zval *return
zf
->
common
.
scope
->
name
)
:
NULL
;
const
char
*
function_name
=
zf
->
common
.
function_name
==
NULL
?
NULL
:
ZSTR_VAL
(
zf
->
common
.
function_name
);
#ifdef SKYWALKING_ENABLED_MYSQLI
int
is_mysqli_function
=
0
;
#endif
char
*
operationName
=
NULL
;
char
*
component
=
NULL
;
if
(
class_name
!=
NULL
)
{
...
...
@@ -274,7 +278,33 @@ ZEND_API void sky_execute_internal(zend_execute_data *execute_data, zval *return
strcat
(
operationName
,
function_name
);
}
}
#ifdef SKYWALKING_ENABLED_MYSQLI
if
(
strcmp
(
class_name
,
"mysqli"
)
==
0
)
{
if
(
strcmp
(
function_name
,
"query"
)
==
0
)
{
component
=
(
char
*
)
emalloc
(
strlen
(
"mysqli"
)
+
1
);
strcpy
(
component
,
"mysqli"
);
operationName
=
(
char
*
)
emalloc
(
strlen
(
class_name
)
+
strlen
(
function_name
)
+
3
);
strcpy
(
operationName
,
class_name
);
strcat
(
operationName
,
"->"
);
strcat
(
operationName
,
function_name
);
}
}
#endif
}
else
if
(
function_name
!=
NULL
)
{
#ifdef SKYWALKING_ENABLED_MYSQLI
if
(
strcmp
(
function_name
,
"mysqli_query"
)
==
0
)
{
class_name
=
"mysqli"
;
function_name
=
"query"
;
component
=
(
char
*
)
emalloc
(
strlen
(
class_name
)
+
1
);
strcpy
(
component
,
class_name
);
operationName
=
(
char
*
)
emalloc
(
strlen
(
class_name
)
+
strlen
(
function_name
)
+
3
);
strcpy
(
operationName
,
class_name
);
strcat
(
operationName
,
"->"
);
strcat
(
operationName
,
function_name
);
is_mysqli_function
=
1
;
}
#endif
}
if
(
operationName
!=
NULL
)
{
...
...
@@ -324,8 +354,27 @@ ZEND_API void sky_execute_internal(zend_execute_data *execute_data, zval *return
add_assoc_string
(
&
tags
,
"db.data_source"
,
(
char
*
)
stmt
->
dbh
->
data_source
);
}
}
}
else
if
(
function_name
!=
NULL
)
{
#ifdef SKYWALKING_ENABLED_MYSQLI
if
(
strcmp
(
class_name
,
"mysqli"
)
==
0
&&
strcmp
(
function_name
,
"query"
)
==
0
)
{
add_assoc_string
(
&
tags
,
"db.type"
,
"mysqli"
);
// params
uint32_t
arg_count
=
ZEND_CALL_NUM_ARGS
(
execute_data
);
if
(
arg_count
)
{
zval
*
p
=
is_mysqli_function
?
ZEND_CALL_ARG
(
execute_data
,
2
)
:
ZEND_CALL_ARG
(
execute_data
,
1
);
//db.statement
switch
(
Z_TYPE_P
(
p
))
{
case
IS_STRING
:
add_assoc_string
(
&
tags
,
"db.statement"
,
Z_STRVAL_P
(
p
));
break
;
}
}
}
#endif
}
zval
temp
;
zval
*
spans
=
NULL
;
zval
*
span_id
=
NULL
;
...
...
@@ -1304,9 +1353,11 @@ PHP_MINIT_FUNCTION (skywalking) {
return
SUCCESS
;
}
// 用户自定义函数执行器(php脚本定义的类、函数)
ori_execute_ex
=
zend_execute_ex
;
zend_execute_ex
=
sky_execute_ex
;
// 内部函数执行器(c语言定义的类、函数)
ori_execute_internal
=
zend_execute_internal
;
zend_execute_internal
=
sky_execute_internal
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录