Skip to content

Commit de905ed

Browse files
authored
Fix console tracing
I noticed that our project lacks spans when executing console commands. I found that upon completion of a console command, only one specific span is finalized, rather than the entire transaction, unlike the behavior in TracingRequestListener. After locally modifying it to complete the transaction and running console sentry:test, I observed the other spans that were previously missing. Therefore, I believe this fix should resolve the issue.
1 parent eaee154 commit de905ed

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/EventListener/TracingConsoleListener.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,12 @@ public function handleConsoleTerminateEvent(ConsoleTerminateEvent $event): void
9191
return;
9292
}
9393

94-
$span = $this->hub->getSpan();
94+
$transaction = $this->hub->getTransaction();
9595

96-
if (null !== $span) {
97-
$span->setStatus(0 === $event->getExitCode() ? SpanStatus::ok() : SpanStatus::internalError());
98-
$span->finish();
96+
if (null !== $transaction) {
97+
$transaction->setStatus(0 === $event->getExitCode() ? SpanStatus::ok() : SpanStatus::internalError());
98+
$transaction->finish();
99+
metrics()->flush();
99100
}
100101
}
101102

0 commit comments

Comments
 (0)