Add traceId and spanId to SwooleTracker

This commit is contained in:
sy-records 2020-01-02 17:13:50 +08:00
parent 5a3ea7303c
commit 54e57e4d62

View File

@ -36,8 +36,10 @@ class HttpServerMiddleware implements MiddlewareInterface
if (class_exists(Stats::class)) {
$path = $request->getUri()->getPath();
$ip = current(swoole_get_local_ip());
$traceId = $request->getHeaderLine("x-swoole-traceid") ?: "";
$spanId = $request->getHeaderLine("x-swoole-spanid") ?: "";
$tick = Stats::beforeExecRpc($path, $this->name, $ip);
$tick = Stats::beforeExecRpc($path, $this->name, $ip, $traceId, $spanId);
try {
$response = $handler->handle($request);
Stats::afterExecRpc($tick, true, $response->getStatusCode());