Skip to content

fix(rack): always detach OTel context token after request#518

Merged
arjun-rajappa merged 1 commit into
masterfrom
rack-context-detach
Jul 9, 2026
Merged

fix(rack): always detach OTel context token after request#518
arjun-rajappa merged 1 commit into
masterfrom
rack-context-detach

Conversation

@arjun-rajappa

Copy link
Copy Markdown
Contributor

OpenTelemetry::Context.detach(@trace_token) was previously called
inside finalize_trace, which is only invoked when
::Instana.tracer.tracing? is true. When tracing is disabled or
suppressed, the token attached in call was never detached, leaving
the OTel context stack in a corrupted state for subsequent requests on
the same thread.

Move the detach call directly into the ensure block of call so it
runs unconditionally, matching the lifecycle of Context.attach.

 was previously called
inside , which is only invoked when
 is true. When tracing is disabled or
suppressed, the token attached in  was never detached, leaving
the OTel context stack in a corrupted state for subsequent requests on
the same thread.

Move the detach call directly into the  block of  so it
runs unconditionally, matching the lifecycle of .

Signed-off-by: Arjun Rajappa <arjun.rajappa@ibm.com>
@arjun-rajappa arjun-rajappa force-pushed the rack-context-detach branch from ca7f879 to 86f4ac7 Compare July 9, 2026 07:51
@sonarqubecloud

sonarqubecloud Bot commented Jul 9, 2026

Copy link
Copy Markdown

@arjun-rajappa arjun-rajappa self-assigned this Jul 9, 2026

@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 merged commit 7bdb8ab into master Jul 9, 2026
231 checks passed
@arjun-rajappa arjun-rajappa deleted the rack-context-detach branch July 9, 2026 09:26
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