Skip to content

Commit bbe0113

Browse files
authored
fix(sentry): adjust event flush order in Integration (#1052)
* fix(sentry): adjust event flush order in Integration Move SentrySdk client flush to after Logs and TraceMetrics flush to ensure proper event ordering during shutdown sequence. * fix(sentry): adjust event flush order for IntegrationRegistry in SingletonAspect * fix(sentry): disable IntegrationRegistry instance creation to prevent unexpected issues --------- Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com>
1 parent 9da8a8a commit bbe0113

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/Aspect/SingletonAspect.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ class SingletonAspect extends AbstractAspect
2121
public array $classes = [
2222
// Singleton Classes
2323
\Sentry\State\HubAdapter::class . '::getInstance',
24-
\Sentry\Integration\IntegrationRegistry::class . '::getInstance',
2524
\Sentry\Logs\Logs::class . '::getInstance',
2625
\Sentry\Metrics\TraceMetrics::class . '::getInstance',
26+
// !!! Don't enable this for now, it may cause some unexpected issues !!!
27+
// \Sentry\Integration\IntegrationRegistry::class . '::getInstance',
2728
// Enums
2829
// \Sentry\CheckInStatus::class . '::getInstance',
2930
// \Sentry\EventType::class . '::getInstance',
@@ -47,14 +48,16 @@ public function process(ProceedingJoinPoint $proceedingJoinPoint)
4748
return match ($className) {
4849
// Singleton Classes
4950
\Sentry\State\HubAdapter::class,
50-
\Sentry\Integration\IntegrationRegistry::class,
5151
\Sentry\Logs\Logs::class => Context::getOrSet($key, function () use ($className) {
5252
return Closure::bind(fn () => new $className(), null, $className)();
5353
}),
5454
\Sentry\Metrics\TraceMetrics::class => Context::getOrSet($key, function () use ($className) {
5555
return new $className();
5656
}),
5757

58+
// !!! Don't enable this for now, it may cause some unexpected issues !!!
59+
// \Sentry\Integration\IntegrationRegistry::class => $proceedingJoinPoint->process(),
60+
5861
// Enums
5962
// \Sentry\CheckInStatus::class,
6063
// \Sentry\EventType::class,

src/Integration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ public static function setTransaction(?string $transaction): void
106106
*/
107107
public static function flushEvents(): void
108108
{
109-
SentrySdk::getCurrentHub()->getClient()?->flush();
110109
Logs::getInstance()->flush();
111110
TraceMetrics::getInstance()->flush();
111+
SentrySdk::getCurrentHub()->getClient()?->flush();
112112
}
113113

114114
/**

0 commit comments

Comments
 (0)