Skip to content

Conversation

@pafuent
Copy link
Contributor

@pafuent pafuent commented Oct 8, 2025

When a span is not recorded, for example when you are sampling traces, the OpenTelemetry::Context attached on request_call is never detached. This happens because handle_response is doing nothing if span.recording? is false.

Here is example of the error that the missing detach generated:

ERROR -- : OpenTelemetry error: calls to detach should match corresponding calls to attach.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Oct 8, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

…ation

When a span is not recorded, for example when you are sampling traces,
the OpenTelemetry::Context attached on `request_call` is never detached.
This happens because `handle_response` is doing nothing if
`span.recording?` is false.

Here is example of the error that the missing detach generated:
```
ERROR -- : OpenTelemetry error: calls to detach should match corresponding calls to attach.
```
@pafuent pafuent force-pushed the instrumentation_excon_fixing_missing_context_detach_when_span_is_not_recorded branch from 05107f0 to b4b77d0 Compare October 8, 2025 17:49
@pafuent pafuent force-pushed the instrumentation_excon_fixing_missing_context_detach_when_span_is_not_recorded branch from c583ed1 to 053afce Compare October 9, 2025 11:03
Copy link
Contributor

@arielvalentin arielvalentin left a comment

Choose a reason for hiding this comment

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

Thank you for this submission and fix!

Copy link
Contributor

@kaylareopelle kaylareopelle left a comment

Choose a reason for hiding this comment

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

Thank you! I really appreciate you adding the fix to all three conventions versions too! 🏆

@arielvalentin arielvalentin enabled auto-merge (squash) October 10, 2025 04:46
@arielvalentin arielvalentin merged commit 6ef349c into open-telemetry:main Oct 10, 2025
64 checks passed
@pafuent pafuent deleted the instrumentation_excon_fixing_missing_context_detach_when_span_is_not_recorded branch October 12, 2025 01:31
americodls pushed a commit to intercom/opentelemetry-ruby-contrib that referenced this pull request Oct 12, 2025
…ation (open-telemetry#1725)

* fix: Fixing missing OpenTelemetry::Context detach on Excon instrumentation

When a span is not recorded, for example when you are sampling traces,
the OpenTelemetry::Context attached on `request_call` is never detached.
This happens because `handle_response` is doing nothing if
`span.recording?` is false.

Here is example of the error that the missing detach generated:
```
ERROR -- : OpenTelemetry error: calls to detach should match corresponding calls to attach.
```

* Fixing tests following action_pack strategy to change the sampler

* Improving datum handling

---------

Co-authored-by: Kayla Reopelle <[email protected]>
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.

3 participants