Skip to content

Skip W3C multi-tenant tracestate keys when converting to OpenCensus - #8810

Merged
jack-berg merged 1 commit into
open-telemetry:mainfrom
thswlsqls:fix/opencensus-shim-tracestate-vendor-key
Sep 14, 2026
Merged

jack-berg merged 1 commit into
open-telemetry:mainfrom
thswlsqls:fix/opencensus-shim-tracestate-vendor-key

Conversation

@thswlsqls

Copy link
Copy Markdown
Contributor

Fixes #8808

Description

  • SpanConverter.mapTracestate(TraceState) passed every entry to Tracestate.Builder.set, which throws IllegalArgumentException: Invalid key fw529a3039@dt for W3C multi-tenant keys (tenant-id@system-id).
  • Once such a key arrived in an incoming tracestate header, Tracer.getCurrentSpan(), spanBuilder(...).startSpan() and TextFormat.extract(...) through the shim all failed.
  • The @ form is the only asymmetry between OpenTelemetry ArrayBasedTraceStateBuilder.isKeyValid and OpenCensus Tracestate.validateKey (length, value and 32-entry rules match), so entries whose key contains @ are now skipped. This mirrors the OpenCensus to OpenTelemetry direction, where TraceStateBuilder.put already drops entries it cannot represent.
  • The delegate OpenTelemetry span keeps the full tracestate; only the OpenCensus view loses the entry.
  • Related: W3C Trace Context key format https://www.w3.org/TR/trace-context/#key, OpenCensus compatibility spec https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/compatibility/opencensus.md

Testing done

  • Added SpanConverterTest#testFromOtelSpanDropsMultiTenantTracestateKeys and OpenTelemetryTextFormatImplTest#testExtractWithW3cDropsMultiTenantTracestateKeys (header tracestate: fw529a3039@dt=fw4,congo=t61rcWkgMzE); both assert only congo=t61rcWkgMzE remains and fail with IllegalArgumentException: Invalid key fw529a3039@dt when the fix is reverted.
  • ./gradlew :opencensus-shim:check passed (65 tests).
  • No CHANGELOG entry (generated at release time); alpha artifact, no apidiff.

@thswlsqls
thswlsqls marked this pull request as ready for review September 12, 2026 10:16
@thswlsqls
thswlsqls requested a review from a team as a code owner September 12, 2026 10:16
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Sep 12, 2026

Copy link
Copy Markdown

Pull request dashboard status

Merged · refreshed 2026-09-14 18:06 UTC

Status above doesn't look right?
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@codecov

codecov Bot commented Sep 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.28%. Comparing base (77b1ac4) to head (5b1972a).

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #8810   +/-   ##
=========================================
  Coverage     91.28%   91.28%           
- Complexity    10528    10530    +2     
=========================================
  Files          1008     1008           
  Lines         28465    28468    +3     
  Branches       3617     3617           
=========================================
+ Hits          25984    25987    +3     
  Misses         1685     1685           
  Partials        796      796           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jack-berg
jack-berg merged commit 3a72cec into open-telemetry:main Sep 14, 2026
35 checks passed
@otelbot

otelbot Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution @thswlsqls! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey.

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.

OpenCensus shim throws IllegalArgumentException on W3C multi-tenant tracestate keys

2 participants