Skip to content

test: add regression tests for OTel context-stack corruption#517

Merged
arjun-rajappa merged 2 commits into
masterfrom
prevent-otel-context-leak
Jul 8, 2026
Merged

test: add regression tests for OTel context-stack corruption#517
arjun-rajappa merged 2 commits into
masterfrom
prevent-otel-context-leak

Conversation

@arjun-rajappa

Copy link
Copy Markdown
Contributor

Add test/instrumentation/otel_context_leak_test.rb covering five instrumentation paths that previously left a non-SpanContext object as the of a non-recording span, causing NoMethodError on the next start_span call on the same thread.

Each test is named after the component and observable behaviour rather than an opaque scenario letter, so failures are self-describing in CI output.

Tests are written against the expected fixed behaviour and are intended to be merged before the corresponding source fixes land, serving as executable acceptance criteria.

Covered paths:

  • Rack: context token not detached when agent is down (rack.rb)
  • rest-client: explicit with_parent on poisoned stack (rest-client.rb)
  • net-http: implicit Context.current fallback, both guard paths (net-http.rb)
  • gRPC: corrupted parent_context passed directly as with_parent (grpc.rb)
  • ActionCable: context stored from Rack-poisoned thread (action_cable.rb)

@arjun-rajappa arjun-rajappa self-assigned this Jul 7, 2026
Add test/instrumentation/otel_context_leak_test.rb covering five
instrumentation paths that previously left a non-SpanContext object as
the  of a non-recording span, causing NoMethodError on the
next start_span call on the same thread.

Each test is named after the component and observable behaviour rather
than an opaque scenario letter, so failures are self-describing in CI
output.

Tests are written against the expected fixed behaviour and are intended
to be merged before the corresponding source fixes land, serving as
executable acceptance criteria.

Covered paths:
- Rack: context token not detached when agent is down (rack.rb)
- rest-client: explicit with_parent on poisoned stack (rest-client.rb)
- net-http: implicit Context.current fallback, both guard paths (net-http.rb)
- gRPC: corrupted parent_context passed directly as with_parent (grpc.rb)
- ActionCable: context stored from Rack-poisoned thread (action_cable.rb)

Signed-off-by: Arjun Rajappa <arjun.rajappa@ibm.com>
@arjun-rajappa arjun-rajappa force-pushed the prevent-otel-context-leak branch from 082fecc to 6a933d9 Compare July 7, 2026 14:58
Signed-off-by: Arjun Rajappa <arjun.rajappa@ibm.com>
@arjun-rajappa arjun-rajappa force-pushed the prevent-otel-context-leak branch from f3c6252 to 73c4aac Compare July 7, 2026 15:22

@pvital pvital left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me.

@arjun-rajappa arjun-rajappa enabled auto-merge (rebase) July 8, 2026 06:45
@arjun-rajappa arjun-rajappa disabled auto-merge July 8, 2026 06:45
@arjun-rajappa arjun-rajappa merged commit bb2d09d into master Jul 8, 2026
222 of 229 checks passed
@arjun-rajappa arjun-rajappa deleted the prevent-otel-context-leak branch July 8, 2026 06:53
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.

2 participants