Skip to content

fix: clear OTel context after span execution#395

Merged
chris-olszewski merged 5 commits intotemporalio:mainfrom
nicobritos:fix-otel-attach
Mar 11, 2026
Merged

fix: clear OTel context after span execution#395
chris-olszewski merged 5 commits intotemporalio:mainfrom
nicobritos:fix-otel-attach

Conversation

@nicobritos
Copy link
Contributor

Ensure Context#detach is called after span execution to avoid spans being associated with incorrect traces.

What was changed

Why?

See #394

Checklist

  1. Closes [Bug] OTeL trace context leaking between workflows when threads/fibers are reused #394

  2. How was this tested:
    See [Bug] OTeL trace context leaking between workflows when threads/fibers are reused #394 for reproduction.

Also, test were added for this case. Commenting temporalio/lib/temporalio/contrib/open_telemetry.rb:83 should fail the test.

  1. Any docs updates needed? No

@nicobritos nicobritos requested a review from a team as a code owner March 5, 2026 14:58
@CLAassistant
Copy link

CLAassistant commented Mar 5, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@chris-olszewski chris-olszewski left a comment

Choose a reason for hiding this comment

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

Thanks for the detailed issue and PR. Looks good to me, just need to update the rbs file with the added _detach_contexts

Ensure Context#detach is called after span execution to avoid
spans being associated with incorrect traces.
@nicobritos
Copy link
Contributor Author

Thanks for the detailed issue and PR. Looks good to me, just need to update the rbs file with the added _detach_contexts

You are right! Sorry, completely missed that. Should be okay now

@chris-olszewski chris-olszewski merged commit 1bb9f6b into temporalio:main Mar 11, 2026
7 checks passed
@nicobritos nicobritos deleted the fix-otel-attach branch March 11, 2026 22:20
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.

[Bug] OTeL trace context leaking between workflows when threads/fibers are reused

3 participants