未验证 提交 59df33de 编写于 作者: 何延龙 提交者: GitHub

Merge pull request #103 from bostin/feature/add_grpc_support

Add Grpc support
......@@ -23,6 +23,7 @@ Host in Beijing. Go to [demo](http://106.75.237.45:8080/).
1. PDO
1. Mysqli
1. Yar Client ([Yar](https://www.php.net/manual/en/book.yar.php))
1. GRPC Client ([GRPC](https://github.com/grpc/grpc-php))
1. Predis Client ([Predis](https://packagist.org/packages/predis/predis))
1. Redis Extension ([Redis Extension](https://github.com/phpredis/phpredis))
......
......@@ -20,6 +20,7 @@
* php PDO扩展发出的请求
* php mysqli扩展发出的请求
* php yar扩展(client)发出的请求
* php [grpc/grpc](https://github.com/grpc/grpc-php) 发出的请求
* php redis扩展发出的请求
* php predis库发出的请求
......
......@@ -188,6 +188,7 @@ ZEND_API void sky_execute_ex(zend_execute_data *execute_data) {
const char *function_name = zf->common.function_name == NULL ? NULL : ZSTR_VAL(zf->common.function_name);
char *operationName = NULL;
int componentId = 0;
if (class_name != NULL) {
if (strcmp(class_name, "Predis\\Client") == 0 && strcmp(function_name, "__call") == 0) {
// params
......@@ -197,11 +198,28 @@ ZEND_API void sky_execute_ex(zend_execute_data *execute_data) {
if (Z_TYPE_P(p) == IS_STRING) {
operationName = (char *) emalloc(strlen(class_name) + strlen(Z_STRVAL_P(p)) + 3);
componentId = COMPONENT_JEDIS;
strcpy(operationName, class_name);
strcat(operationName, "->");
strcat(operationName, Z_STRVAL_P(p));
}
}
} else if (strcmp(class_name, "Grpc\\BaseStub") == 0) {
if (strcmp(function_name, "_simpleRequest") == 0
|| strcmp(function_name, "_clientStreamRequest") == 0
|| strcmp(function_name, "_serverStreamRequest") == 0
|| strcmp(function_name, "_bidiRequest") == 0
) {
operationName = (char *) emalloc(strlen(class_name) + strlen(function_name) + 3);
if (SKYWALKING_G(version) == 5) {
componentId = COMPONENT_GRPC;
} else {
componentId = COMPONENT_RPC;
}
strcpy(operationName, class_name);
strcat(operationName, "->");
strcat(operationName, function_name);
}
}
}
......@@ -268,6 +286,12 @@ ZEND_API void sky_execute_ex(zend_execute_data *execute_data) {
}
}
}
} else if (strcmp(class_name, "Grpc\\BaseStub") == 0) {
add_assoc_string(&tags, "rpc.type", "grpc");
zval *p = ZEND_CALL_ARG(execute_data, 1);
if (Z_TYPE_P(p) == IS_STRING) {
add_assoc_string(&tags, "rpc.method", Z_STRVAL_P(p));
}
}
zval temp;
......@@ -289,7 +313,7 @@ ZEND_API void sky_execute_ex(zend_execute_data *execute_data) {
add_assoc_long(&temp, "startTime", millisecond);
add_assoc_long(&temp, "spanType", 1);
add_assoc_long(&temp, "spanLayer", 1);
add_assoc_long(&temp, "componentId", COMPONENT_JEDIS);
add_assoc_long(&temp, "componentId", componentId);
add_assoc_string(&temp, "operationName", operationName);
add_assoc_string(&temp, "peer", "");
efree(operationName);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册