Skip to content

Commit

Permalink
Fix trace context being lost when finishing queue transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
stayallive committed Dec 17, 2023
1 parent c8de534 commit ff3c28d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Sentry/Laravel/Features/QueueIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Sentry\Tracing\PropagationContext;
use Sentry\Tracing\SpanContext;
use Sentry\Tracing\SpanStatus;
use Sentry\Tracing\Transaction;
use Sentry\Tracing\TransactionContext;
use Sentry\Tracing\TransactionSource;

Expand Down Expand Up @@ -169,8 +170,20 @@ private function finishJobWithStatus(SpanStatus $status): void
$span = $this->maybePopSpan();

if ($span !== null) {
$span->finish();
$hub = SentrySdk::getCurrentHub();

$currentSpan = $hub->getSpan();

if ($span instanceof Transaction) {
$hub->setSpan($span);
}

$span->setStatus($status);
$span->finish();

if ($span instanceof Transaction) {
$hub->setSpan($currentSpan);
}
}
}

Expand Down

0 comments on commit ff3c28d

Please sign in to comment.