Fix span link span ID hex padding - #12279
Open
itsamenathan wants to merge 2 commits into
Open
Conversation
DDSpanLink serialises link ids into the _dd.span_links tag with DDTraceId.toHexString for the trace id, which pads to 32 characters, but DDSpanId.toHexString for the span id, which delegates to Long.toHexString and strips leading zeros. Span ids are generated as non-zero positive longs, so the leading hex nibble is zero for one id in eight and those ids serialise to 15 characters or fewer. Consumers that treat the field as fixed-width hex reject them: the OpenTelemetry Collector's Datadog receiver calls SpanIDFromHex, which requires exactly 16 characters, and drops the link. The trace id is unaffected because both DD64bTraceId and DD128bTraceId pad to 32. Use DDSpanId.toHexStringPadded, which is the existing padded variant on the same class, so the emitted id is always 16 characters.
itsamenathan
requested review from
AlexeyKuznetsov-DD
and removed request for
a team
August 24, 2026 22:03
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Does This Do
Pads the
span_idfield emitted in the_dd.span_linkstag to 16 hexcharacters, matching the existing padding behavior of
trace_id.Motivation
DDSpanLinkserializes span link ids usingDDTraceId.toHexString()forthe trace id, which is zero-padded to 32 characters, but
DDSpanId.toHexString()for the span id, which delegates toLong.toHexStringand strips leading zeros. Since span ids are generatedas non-zero positive longs, about 1 in 16 span ids has a zero leading
nibble and serializes to 15 characters instead of 16.
Consumers that parse this field as fixed-width hex reject it: the
OpenTelemetry Collector's Datadog receiver calls
SpanIDFromHex, whichrequires exactly 16 characters, and drops the link.
trace_idisunaffected because both
DD64bTraceIdandDD128bTraceIdalready padto 32.
Additional Notes
Uses
DDSpanId.toHexStringPadded, an existing padded variant already onthe same class, rather than changing
DDSpanId.toHexStringitself —that method is a separate shared utility used elsewhere (e.g. B3 header
encoding, trace export JSON) where the unpadded form is intentional and
tested.