Skip to content

Commit 4177cd2

Browse files
committed
fix: improve span handling in AsyncQueueJobMessageAspect to prevent null reference
1 parent 6cad491 commit 4177cd2

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/Tracing/Aspect/AsyncQueueJobMessageAspect.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,16 @@ public function handlePush(ProceedingJoinPoint $proceedingJoinPoint)
9494

9595
return trace(
9696
function (Scope $scope) use ($proceedingJoinPoint, $messageId, $destinationName, $bodySize) {
97-
$span = $scope->getSpan();
98-
$carrier = Carrier::fromSpan($span)->with([
99-
'publish_time' => microtime(true),
100-
'message_id' => $messageId,
101-
'destination_name' => $destinationName,
102-
'body_size' => $bodySize,
103-
]);
104-
105-
Context::set(Constants::TRACE_CARRIER, $carrier);
97+
if ($span = $scope->getSpan()) {
98+
$carrier = Carrier::fromSpan($span)->with([
99+
'publish_time' => microtime(true),
100+
'message_id' => $messageId,
101+
'destination_name' => $destinationName,
102+
'body_size' => $bodySize,
103+
]);
104+
105+
Context::set(Constants::TRACE_CARRIER, $carrier);
106+
}
106107

107108
return $proceedingJoinPoint->process();
108109
},

0 commit comments

Comments
 (0)