Skip to content

fix(tracer): support converting OpenTelemetry parent span context - #904

Merged
pvital merged 4 commits into
mainfrom
fix/support-otel-parent-span-context
Oct 14, 2026
Merged

pvital merged 4 commits into
mainfrom
fix/support-otel-parent-span-context

Conversation

@arjun-rajappa

Copy link
Copy Markdown
Contributor

Allow OpenTelemetry SpanContext instances in start_span by converting valid non-Instana parent contexts into Instana SpanContext objects instead of raising a TypeError. If the context is invalid, fall back to None. Include debug logs for parent context conversion and invalid context resets.

@arjun-rajappa
arjun-rajappa requested a review from a team as a code owner September 17, 2026 05:07
@pvital pvital added bug fix OTel OpenTelemetry compatibility. labels Sep 17, 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.

@arjun-rajappa, can you add specific start_span test cases with context arguments with OTel and Instana SpanContext? You can use the Pytest parametrization for that.

@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.

@CagriYonca CagriYonca left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A few comments

Comment thread src/instana/tracer.py Outdated
Comment thread tests/test_tracer.py Outdated
@pvital

pvital commented Oct 9, 2026

Copy link
Copy Markdown
Member

@arjun-rajappa could you rebase and check @CagriYonca requests, please?

Allow OpenTelemetry SpanContext instances in start_span by converting
valid non-Instana parent contexts into Instana SpanContext objects instead
of raising a TypeError. If the context is invalid, fall back to None.
Include debug logs for parent context conversion and invalid context resets.

Signed-off-by: Arjun Rajappa <arjun.rajappa@ibm.com>
… Context

Signed-off-by: Arjun Rajappa <arjun.rajappa@ibm.com>
@pvital
pvital force-pushed the fix/support-otel-parent-span-context branch from a57b79e to 93cd60d Compare October 13, 2026 11:15
pvital and others added 2 commits October 13, 2026 13:25
Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
Convert 128-bit OpenTelemetry parent trace IDs to 64-bit integers while preserving the full 32-character hex ID in long_trace_id, and default trace_parent to None. Update parametrized test cases to cover both 128-bit and 64-bit parent contexts.

Signed-off-by: Arjun Rajappa <arjun.rajappa@ibm.com>

@CagriYonca CagriYonca left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me, thanks Arjun!

@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.

@pvital
pvital merged commit a449ceb into main Oct 14, 2026
20 checks passed
@pvital
pvital deleted the fix/support-otel-parent-span-context branch October 14, 2026 10:11
CagriYonca added a commit that referenced this pull request Oct 15, 2026
…xt (issue #879)

Add test_w3c_traceparent_upstream_context to verify that FastAPI >= 0.142.0
correctly handles incoming W3C traceparent headers without raising TypeError.

- Sends a real traceparent header via TestClient
- Asserts HTTP 200 (not 500)
- Verifies upstream trace_id (lower 64-bit) and span_id are preserved in the ASGI span
- Checks X-INSTANA-T, X-INSTANA-S, Server-Timing response headers are present

Ref: #879
PR: #904
Signed-off-by: Cagri Yonca <cagri@ibm.com>
CagriYonca added a commit that referenced this pull request Oct 15, 2026
…xt (issue #879)

Add test_w3c_traceparent_upstream_context to verify that FastAPI >= 0.142.0
correctly handles incoming W3C traceparent headers without raising TypeError.

- Sends a real traceparent header via TestClient
- Asserts HTTP 200 (not 500)
- Verifies upstream trace_id (lower 64-bit) and span_id are preserved in the ASGI span
- Checks X-INSTANA-T, X-INSTANA-S, Server-Timing response headers are present

Ref: #879
PR: #904
Signed-off-by: Cagri Yonca <cagri@ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug fix OTel OpenTelemetry compatibility.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants