From 6ebb71f2005f864c6b9f6e7e0550632a7ca643b8 Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Thu, 25 Dec 2025 13:48:12 +0800 Subject: [PATCH 1/2] refactor(sentry): remove redundant Integration::flushEvents() calls from defer callbacks This change removes redundant Integration::flushEvents() calls from multiple defer callbacks in EventHandleListener. The event flushing is already handled in the finally block of the handleCommandFinished method, making these calls unnecessary and potentially causing performance issues due to duplicate flushes. The redundant calls are removed from: - handleRequestReceived defer callback (HTTP/RPC request handling) - handleCrontabTaskStarting defer callback (Crontab task execution) - handleAmqpMessageProcessing defer callback (AMQP message processing) - handleKafkaMessageProcessing defer callback (Kafka message processing) - handleAsyncQueueJobProcessing defer callback (AsyncQueue job processing) This refactoring improves code clarity and ensures event flushing occurs only once per command execution cycle. --- .../src/Tracing/Listener/EventHandleListener.php | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/sentry/src/Tracing/Listener/EventHandleListener.php b/src/sentry/src/Tracing/Listener/EventHandleListener.php index a8042e226..978273b16 100644 --- a/src/sentry/src/Tracing/Listener/EventHandleListener.php +++ b/src/sentry/src/Tracing/Listener/EventHandleListener.php @@ -337,9 +337,6 @@ protected function handleRequestReceived(HttpEvent\RequestReceived|RpcEvent\Requ // Finish transaction $transaction->finish(); - - // Flush events - Integration::flushEvents(); }); } @@ -538,9 +535,6 @@ protected function handleCrontabTaskStarting(CrontabEvent\BeforeExecute $event): // Finish transaction $transaction->finish(); - - // Flush events - Integration::flushEvents(); }); } @@ -607,9 +601,6 @@ protected function handleAmqpMessageProcessing(AmqpEvent\BeforeConsume $event): // Finish transaction $transaction->finish(); - - // Flush events - Integration::flushEvents(); }); } @@ -675,9 +666,6 @@ protected function handleKafkaMessageProcessing(KafkaEvent\BeforeConsume $event) // Finish transaction $transaction->finish(); - - // Flush events - Integration::flushEvents(); }); } @@ -725,9 +713,6 @@ protected function handleAsyncQueueJobProcessing(AsyncQueueEvent\BeforeHandle $e // Finish transaction $transaction->finish(); - - // Flush events - Integration::flushEvents(); }); } From f97b01d422fd1e9882109848e2a76fa03f46086b Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Thu, 25 Dec 2025 13:49:19 +0800 Subject: [PATCH 2/2] chore: disable Sentry SingletonAspect registration --- src/sentry/src/ConfigProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sentry/src/ConfigProvider.php b/src/sentry/src/ConfigProvider.php index ec1a23caf..e101e53cb 100644 --- a/src/sentry/src/ConfigProvider.php +++ b/src/sentry/src/ConfigProvider.php @@ -27,7 +27,7 @@ public function __invoke(): array Aspect\GuzzleHttpClientAspect::class, Aspect\LoggerAspect::class, Aspect\RedisAspect::class, - Aspect\SingletonAspect::class, + // Aspect\SingletonAspect::class, Metrics\Aspect\CounterAspect::class, Metrics\Aspect\HistogramAspect::class, Tracing\Aspect\AmqpProducerAspect::class,