File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -86,21 +86,26 @@ public function traceExtras(): array
8686 $ context = \OpenTelemetry \Context \Context::getCurrent ();
8787 $ spanContext = \OpenTelemetry \API \Trace \Span::fromContext ($ context )->getContext ();
8888
89- return [
90- 'trace ' => [
91- 'id ' => $ spanContext ->getTraceId (),
92- ],
93- ];
89+ if ($ spanContext ->isValid ()){
90+ return [
91+ 'trace ' => [
92+ 'id ' => $ spanContext ->getTraceId (),
93+ ],
94+ ];
95+ }
9496 }
9597
9698 if (class_exists (\Elastic \Apm \ElasticApm::class)) {
9799 $ traceId = \Elastic \Apm \ElasticApm::getCurrentTransaction ()->getTraceId ();
98100
99- return [
100- 'trace ' => [
101- 'id ' => $ traceId ,
102- ],
103- ];
101+ // Only return a trace id if valid, i.e. not all zeros
102+ if ($ traceId !== '00000000000000000000000000000000 ' ) {
103+ return [
104+ 'trace ' => [
105+ 'id ' => $ traceId ,
106+ ],
107+ ];
108+ }
104109 }
105110
106111 return [];
You can’t perform that action at this time.
0 commit comments