Skip to content

Emit decimal span_id and zero-padded 32-char hex trace_id in RUM resource events#185

Merged
ambushwork merged 1 commit into
developfrom
yl/fix-span-id
Jun 12, 2026
Merged

Emit decimal span_id and zero-padded 32-char hex trace_id in RUM resource events#185
ambushwork merged 1 commit into
developfrom
yl/fix-span-id

Conversation

@ambushwork

Copy link
Copy Markdown
Member

What does this PR do?

Fixes RUM → APM correlation for resources tracked via DdUrlTransfer. RUM resource events now carry a backend-valid _dd.trace_id (32-char zero-padded hexadecimal) and _dd.span_id (decimal), so the rum-span-mapper backend can generate the corresponding APM span instead of silently dropping the event.

Trace IDs were appearing on the RUM side but the trace was never propagated to APM.

image

The rum-span-mapper backend validates each RUM resource before generating a span:

The Roku SDK violated both:

Header type span_id written to event Result
datadog decimal trace_id sometimes unpadded → intermittently dropped
b3 / b3multi / tracecontext hexadecimal INVALID_SPAN_ID → always dropped

A hex span_id containing any a–f fails isDigits, so for the W3C/B3 header types correlation essentially never worked; an unpadded trace_id (leading-zero nibbles) caused intermittent failures across all types.

Changes

  • Added generateTraceId() / generateSpanId() helpers that generate an id once and expose every representation each consumer needs (decimal, 16-char and 32-char zero-padded hex).
  • Reworked _addSampledInHeaders so the RUM event always stores traceId as 32-char padded hex and spanId as decimal, while each wire header keeps its own required format (datadog low-decimal + _dd.p.tid hex, b3/b3multi/tracecontext padded hex).

After change

image

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@datadog-datadog-prod-us1-2

This comment has been minimized.

@ambushwork

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ambushwork
ambushwork marked this pull request as ready for review June 10, 2026 08:47
@ambushwork
ambushwork requested a review from a team as a code owner June 10, 2026 08:47
@ambushwork
ambushwork merged commit fbb6b3b into develop Jun 12, 2026
7 of 8 checks passed
@ambushwork
ambushwork deleted the yl/fix-span-id branch June 12, 2026 14:51
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.

2 participants