Skip to content

Commit 80a4dab

Browse files
cursoragentclaude
andcommitted
fix(effect): Add final metrics flush before layer teardown
Before this fix, when SentryEffectMetricsLayer was torn down, the release effect only cleared previousCounterValues without flushing accumulated metrics. Since the scoped fiber running the periodic reporter is interrupted on scope finalization, any metrics accumulated since the last 10-second flush were silently lost. This fix adds a final flush before clearing the state, ensuring all metrics are sent to Sentry before the layer is finalized. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 5b1c7d8 commit 80a4dab

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

packages/effect/src/metrics.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ export const SentryEffectMetricsLayer: Layer.Layer<never, never, never> = scoped
126126

127127
yield* Effect.acquireRelease(Effect.void, () =>
128128
Effect.sync(() => {
129+
flushMetricsToSentry(previousCounterValues);
129130
previousCounterValues.clear();
130131
}),
131132
);

0 commit comments

Comments
 (0)