Skip to content

增加链路对象参数 $request->tracer = $tracer;#4

Merged
walkor merged 1 commit intowebman-php:mainfrom
Tinywan:patch-1
Apr 30, 2022
Merged

增加链路对象参数 $request->tracer = $tracer;#4
walkor merged 1 commit intowebman-php:mainfrom
Tinywan:patch-1

Conversation

@Tinywan
Copy link
Member

@Tinywan Tinywan commented Apr 29, 2022

自定义子链路案例

if(isset(request()->tracer) && isset(request()->rootSpan)){
    $exceptionSpan = request()->tracer->newChild(request()->rootSpan->getContext());
    $exceptionSpan->setName('exception');
    $exceptionSpan->start();
    $exceptionSpan->tag('error.code', (string) $errorCode);
    $value = [
        'event' => 'error',
        'message' => $errorMessage,
        'stack' => 'Exception:'.$e->getFile().'|'.$e->getLine(),
    ];
    $exceptionSpan->annotate(json_encode($value));
    $exceptionSpan->finish();
}

@walkor walkor merged commit 7a89ea5 into webman-php:main Apr 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants