Skip to content

Remove OTEL Activity from circuit breaker to fix trace ID leak#2495

Merged
jeremydmiller merged 1 commit into
mainfrom
fix/2494-circuit-breaker-otel-trace-leak
Apr 10, 2026
Merged

Remove OTEL Activity from circuit breaker to fix trace ID leak#2495
jeremydmiller merged 1 commit into
mainfrom
fix/2494-circuit-breaker-otel-trace-leak

Conversation

@jeremydmiller

Copy link
Copy Markdown
Member

Summary

  • Fixes TraceID leaked after Circuit Break trigger/resume cycle (kafka transport) #2494 — after a circuit breaker trip/resume cycle, all subsequent messages inherited a stale trace ID from the circuit breaker's Activity
  • Removes the Activity creation from the circuit breaker trip handler (CircuitBreaker.UpdateTotalsAsync) and the listener PauseAsync method
  • The root cause was Activity.Current (stored in AsyncLocal) leaking from the background batching thread into message processing threads after the listener restarted

Test plan

  • Verify with a Kafka consumer + circuit breaker that each message gets a unique trace ID after CB resume
  • Confirm other OTEL spans (stop listener, back-pressure pause) are unaffected

🤖 Generated with Claude Code

…leak (#2494)

After a circuit breaker trip/resume cycle, the Activity started on the
background batching thread leaked its trace context via AsyncLocal into
subsequent message processing, causing all new messages to inherit the
stale trace ID. Remove the Activity creation from both the circuit
breaker trip handler and the listener PauseAsync method to prevent
this contamination.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jeremydmiller jeremydmiller merged commit 0d86ce7 into main Apr 10, 2026
17 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TraceID leaked after Circuit Break trigger/resume cycle (kafka transport)

1 participant