Skip to content

Reproduce RUMS-3855: invalid W3C traceparent parentId decimal encoding#3360

Closed
mariusc83 wants to merge 2 commits intodevelopfrom
mariusc83/RUMS-3855/traceparent-invalid-version
Closed

Reproduce RUMS-3855: invalid W3C traceparent parentId decimal encoding#3360
mariusc83 wants to merge 2 commits intodevelopfrom
mariusc83/RUMS-3855/traceparent-invalid-version

Conversation

@mariusc83
Copy link
Copy Markdown
Member

Reproduction for RUMS-3855

Jira: RUMS-3855

Issue Summary

TracingInterceptor generates invalid W3C traceparent headers when a span is not sampled: it converts spanId via Long.toString() (decimal) instead of hex encoding, producing a parentId field that may exceed 16 characters. This causes "Invalid traceparent version" errors on the backend.

Reproduction Tests

Failing tests demonstrating the bug in TracingInterceptor.

What the Tests Prove

The parentId field in the generated traceparent header contains decimal digits and is not properly bounded to 16 hex characters, violating the W3C Trace Context specification.

Root Cause Analysis

TracingInterceptor.handleW3CNotSampledHeaders() calls span.context().toSpanId() which returns a decimal representation of the Long spanId (up to 20 chars) instead of the required 16-char hex string.

Call Chain

TracingInterceptor.interceptAndTrace()
→ TracingInterceptor.updateRequest() [isSampled=false branch]
→ TracingInterceptor.setSampledOutHeaders()
→ TracingInterceptor.handleW3CNotSampledHeaders(span, requestBuilder)
→ span.context().toSpanId() [returns DECIMAL, not hex]
→ W3C_TRACEPARENT_DROP_SAMPLING_DECISION.format(traceId, spanId.padStart(16, '0'))
→ addHeader('traceparent', '00-{32hex}-{decimalSpanId}-00') [>55 chars when spanId >16 decimal digits]
→ Backend: ValueError: Invalid traceparent version

Failure Output

Test 1: traceparent must be exactly 55 chars per W3C spec — actual header '00-{32hex}-9223372036854775807-00' is 58 chars (expected 55).
Test 2: traceparent must match W3C pattern '00-[0-9a-f]{32}-[0-9a-f]{16}-0[01]' — parentId '9223372036854775807' is 19 decimal digits, not 16 hex chars.


Generated by rum:tee-triage-insights

@mariusc83 mariusc83 closed this Apr 9, 2026
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.

1 participant