From a387a81c8b9bac94769879afede94e8b0360f232 Mon Sep 17 00:00:00 2001 From: Deeka Wong Date: Thu, 9 Nov 2023 11:56:24 +0800 Subject: [PATCH] Fix the bug that cannot match FailToExecute (#414) Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com> --- .../src/Tracing/Listener/TracingCrontabListener.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sentry/src/Tracing/Listener/TracingCrontabListener.php b/src/sentry/src/Tracing/Listener/TracingCrontabListener.php index 0c74adc70..b9c53bc27 100644 --- a/src/sentry/src/Tracing/Listener/TracingCrontabListener.php +++ b/src/sentry/src/Tracing/Listener/TracingCrontabListener.php @@ -35,9 +35,9 @@ public function __construct( public function listen(): array { return [ - BeforeExecute::class, // @phpstan-ignore-line + BeforeExecute::class, FailToExecute::class, - AfterExecute::class, // @phpstan-ignore-line + AfterExecute::class, ]; } @@ -47,12 +47,12 @@ public function listen(): array public function process(object $event): void { match ($event::class) { - BeforeExecute::class => $this->startTransaction($event), // @phpstan-ignore-line - AfterExecute::class => $this->finishTransaction($event), // @phpstan-ignore-line + BeforeExecute::class => $this->startTransaction($event), + AfterExecute::class, FailToExecute::class => $this->finishTransaction($event), }; } - protected function startTransaction(BeforeExecute $event): void // @phpstan-ignore-line + protected function startTransaction(BeforeExecute $event): void { $sentry = SentrySdk::init(); /** @var Crontab $crontab */ @@ -93,7 +93,7 @@ protected function startTransaction(BeforeExecute $event): void // @phpstan-igno TraceContext::setSpan($transaction); } - protected function finishTransaction(AfterExecute|FailToExecute $event): void // @phpstan-ignore-line + protected function finishTransaction(AfterExecute|FailToExecute $event): void { $transaction = TraceContext::getTransaction();