Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
SkyAPM
SkyAPM-php-sdk
提交
60395d6b
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,发现更多精彩内容 >>
提交
60395d6b
编写于
1月 03, 2019
作者:
H
heyanlong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix 7.0.x
上级
844932a3
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
42 addition
and
28 deletion
+42
-28
sky-php7ext/skywalking.c
sky-php7ext/skywalking.c
+42
-28
未找到文件。
sky-php7ext/skywalking.c
浏览文件 @
60395d6b
...
@@ -148,43 +148,56 @@ void sky_curl_exec_handler(INTERNAL_FUNCTION_PARAMETERS)
...
@@ -148,43 +148,56 @@ void sky_curl_exec_handler(INTERNAL_FUNCTION_PARAMETERS)
zval
*
spans
=
NULL
;
zval
*
spans
=
NULL
;
zval
*
last_span
=
NULL
;
zval
*
last_span
=
NULL
;
zval
*
span_id
=
NULL
;
zval
*
span_id
=
NULL
;
smart_str
peer
=
{
0
};
ssize_t
operation_name_l
=
0
;
smart_str
operation_name
=
{
0
};
char
*
peer
=
NULL
;
char
*
operation_name
=
(
char
*
)
emalloc
(
sizeof
(
char
));
bzero
(
operation_name
,
sizeof
(
char
));
if
(
is_send
==
1
)
{
if
(
is_send
==
1
)
{
int
peer_port
=
0
;
int
peer_port
=
0
;
if
(
url_info
->
port
)
{
if
(
url_info
->
port
)
{
peer_port
=
url_info
->
port
;
peer_port
=
url_info
->
port
;
}
if
(
peer_port
>
0
)
{
smart_str_append_printf
(
&
peer
,
"%s:%d"
,
url_info
->
host
,
peer_port
);
}
else
{
}
else
{
if
(
strcasecmp
(
"http"
,
url_info
->
scheme
)
==
0
)
{
if
(
strcasecmp
(
"http"
,
url_info
->
scheme
)
==
0
)
{
smart_str_append_printf
(
&
peer
,
"%s:%d"
,
url_info
->
host
,
80
)
;
peer_port
=
80
;
}
else
{
}
else
{
smart_str_append_printf
(
&
peer
,
"%s:%d"
,
url_info
->
host
,
443
)
;
peer_port
=
443
;
}
}
}
}
smart_str_0
(
&
peer
);
peer
=
(
char
*
)
emalloc
(
strlen
(
url_info
->
host
)
+
7
);
bzero
(
peer
,
strlen
(
url_info
->
host
)
+
7
);
sprintf
(
peer
,
"%s:%d"
,
url_info
->
host
,
peer_port
);
if
(
url_info
->
query
)
{
if
(
url_info
->
query
)
{
if
(
url_info
->
path
==
NULL
)
{
if
(
url_info
->
path
==
NULL
)
{
smart_str_append_printf
(
&
operation_name
,
"%s?%s"
,
"/"
,
url_info
->
query
);
operation_name_l
=
snprintf
(
NULL
,
0
,
"%s?%s"
,
"/"
,
url_info
->
query
);
erealloc
(
operation_name
,
operation_name_l
+
1
);
bzero
(
operation_name
,
operation_name_l
+
1
);
snprintf
(
operation_name
,
operation_name_l
+
1
,
"%s?%s"
,
"/"
,
url_info
->
query
);
}
else
{
}
else
{
smart_str_append_printf
(
&
operation_name
,
"%s?%s"
,
url_info
->
path
,
url_info
->
query
);
operation_name_l
=
snprintf
(
NULL
,
0
,
"%s?%s"
,
url_info
->
path
,
url_info
->
query
);
erealloc
(
operation_name
,
operation_name_l
+
1
);
bzero
(
operation_name
,
operation_name_l
+
1
);
snprintf
(
operation_name
,
operation_name_l
+
1
,
"%s?%s"
,
url_info
->
path
,
url_info
->
query
);
}
}
}
else
{
}
else
{
if
(
url_info
->
path
==
NULL
)
{
if
(
url_info
->
path
==
NULL
)
{
smart_str_append_printf
(
&
operation_name
,
"%s"
,
"/"
);
operation_name_l
=
snprintf
(
NULL
,
0
,
"%s"
,
"/"
);
erealloc
(
operation_name
,
operation_name_l
+
1
);
bzero
(
operation_name
,
operation_name_l
+
1
);
snprintf
(
operation_name
,
operation_name_l
+
1
,
"%s"
,
"/"
);
}
else
{
}
else
{
smart_str_append_printf
(
&
operation_name
,
"%s"
,
url_info
->
path
);
operation_name_l
=
snprintf
(
NULL
,
0
,
"%s"
,
url_info
->
path
);
erealloc
(
operation_name
,
operation_name_l
+
1
);
bzero
(
operation_name
,
operation_name_l
+
1
);
snprintf
(
operation_name
,
operation_name_l
+
1
,
"%s"
,
url_info
->
path
);
}
}
}
}
smart_str_0
(
&
operation_name
);
spans
=
get_spans
();
spans
=
get_spans
();
last_span
=
zend_hash_index_find
(
Z_ARRVAL_P
(
spans
),
zend_hash_num_elements
(
Z_ARRVAL_P
(
spans
))
-
1
);
last_span
=
zend_hash_index_find
(
Z_ARRVAL_P
(
spans
),
zend_hash_num_elements
(
Z_ARRVAL_P
(
spans
))
-
1
);
span_id
=
zend_hash_str_find
(
Z_ARRVAL_P
(
last_span
),
"spanId"
,
sizeof
(
"spanId"
)
-
1
);
span_id
=
zend_hash_str_find
(
Z_ARRVAL_P
(
last_span
),
"spanId"
,
sizeof
(
"spanId"
)
-
1
);
sw3
=
generate_sw3
(
Z_LVAL_P
(
span_id
)
+
1
,
ZSTR_VAL
(
peer
.
s
),
ZSTR_VAL
(
operation_name
.
s
)
);
sw3
=
generate_sw3
(
Z_LVAL_P
(
span_id
)
+
1
,
peer
,
operation_name
);
}
}
...
@@ -221,6 +234,7 @@ void sky_curl_exec_handler(INTERNAL_FUNCTION_PARAMETERS)
...
@@ -221,6 +234,7 @@ void sky_curl_exec_handler(INTERNAL_FUNCTION_PARAMETERS)
zval_dtor
(
&
argv
[
0
]);
zval_dtor
(
&
argv
[
0
]);
zval_dtor
(
&
argv
[
1
]);
zval_dtor
(
&
argv
[
1
]);
zval_dtor
(
&
argv
[
2
]);
zval_dtor
(
&
argv
[
2
]);
efree
(
sw3
);
}
}
zval
temp
;
zval
temp
;
...
@@ -263,10 +277,10 @@ void sky_curl_exec_handler(INTERNAL_FUNCTION_PARAMETERS)
...
@@ -263,10 +277,10 @@ void sky_curl_exec_handler(INTERNAL_FUNCTION_PARAMETERS)
add_assoc_long
(
&
temp
,
"endTime"
,
millisecond
);
add_assoc_long
(
&
temp
,
"endTime"
,
millisecond
);
add_assoc_string
(
&
temp
,
"operationName"
,
ZSTR_VAL
(
operation_name
.
s
)
);
add_assoc_string
(
&
temp
,
"operationName"
,
operation_name
);
add_assoc_string
(
&
temp
,
"peer"
,
ZSTR_VAL
(
peer
.
s
)
);
add_assoc_string
(
&
temp
,
"peer"
,
peer
);
smart_str_free
(
&
peer
);
efree
(
peer
);
smart_str_free
(
&
operation_name
);
efree
(
operation_name
);
php_url_free
(
url_info
);
php_url_free
(
url_info
);
...
@@ -410,16 +424,16 @@ static char *generate_sw3(zend_long span_id, char *peer_host, char *operation_na
...
@@ -410,16 +424,16 @@ static char *generate_sw3(zend_long span_id, char *peer_host, char *operation_na
sizeof
(
"entryOperationName"
)
-
1
);
sizeof
(
"entryOperationName"
)
-
1
);
zval
*
distributedTraceId
=
zend_hash_str_find
(
Z_ARRVAL
(
SKYWALKING_G
(
context
)),
"distributedTraceId"
,
zval
*
distributedTraceId
=
zend_hash_str_find
(
Z_ARRVAL
(
SKYWALKING_G
(
context
)),
"distributedTraceId"
,
sizeof
(
"distributedTraceId"
)
-
1
);
sizeof
(
"distributedTraceId"
)
-
1
);
ssize_t
sw3_l
=
0
;
s
mart_str
sw3
=
{
0
};
s
w3_l
=
snprintf
(
NULL
,
0
,
"sw3: %s|%d|%d|%d|#%s|#%s|#%s|%s"
,
Z_STRVAL_P
(
traceId
),
span_id
,
application_instance
,
Z_LVAL_P
(
entryApplicationInstance
),
peer_host
,
smart_str_append_printf
(
&
sw3
,
"sw3: %s|%d|%d|%d|#%s|#%s|#%s|%s"
,
Z_STRVAL_P
(
traceId
),
span_id
,
Z_STRVAL_P
(
entryOperationName
),
operation_name
,
Z_STRVAL_P
(
distributedTraceId
));
application_instance
,
Z_LVAL_P
(
entryApplicationInstance
),
peer_host
,
char
*
sw3
=
(
char
*
)
emalloc
(
sw3_l
+
1
);
Z_STRVAL_P
(
entryOperationName
),
operation_name
,
Z_STRVAL_P
(
distributedTraceId
)
);
bzero
(
sw3
,
sw3_l
+
1
);
s
mart_str_0
(
&
sw3
);
s
nprintf
(
sw3
,
sw3_l
+
1
,
"sw3: %s|%d|%d|%d|#%s|#%s|#%s|%s"
,
Z_STRVAL_P
(
traceId
),
span_id
,
char
*
header
=
ZSTR_VAL
(
sw3
.
s
);
application_instance
,
Z_LVAL_P
(
entryApplicationInstance
),
peer_host
,
smart_str_free
(
&
sw3
);
Z_STRVAL_P
(
entryOperationName
),
operation_name
,
Z_STRVAL_P
(
distributedTraceId
)
);
return
header
;
return
sw3
;
}
}
static
zend_string
*
trim_sharp
(
zval
*
tmp
)
{
static
zend_string
*
trim_sharp
(
zval
*
tmp
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录