Skip to content

⚗️ Add 128-bit trace IDs for Browser RUM - #4926

Draft
BeltranBulbarellaDD wants to merge 1 commit into
mainfrom
beltran.bulbarella/Browser-SDK-128-bit-trace-ID
Draft

⚗️ Add 128-bit trace IDs for Browser RUM#4926
BeltranBulbarellaDD wants to merge 1 commit into
mainfrom
beltran.bulbarella/Browser-SDK-128-bit-trace-ID

Conversation

@BeltranBulbarellaDD

@BeltranBulbarellaDD BeltranBulbarellaDD commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Draft: waiting for approval on the RFC.

Motivation

Browser RUM currently generates 64-bit trace IDs and stores them as decimal on resource events. APM, mobile SDKs, and LLM Observability use 128-bit hexadecimal IDs, so Browser-started traces cannot be joined through one shared representation without extracting the low 64 bits and converting it to hexadecimal.

This PR introduces 128-bit trace IDs behind the trace_id_128_bit experimental feature. The existing 64-bit behavior remains the default while we dogfood and validate end-to-end correlation and CORS behavior.

Changes

  • Generate trace IDs using <32-bit Unix timestamp><32 zero bits><64 random bits>.
  • Add explicit low-decimal, full-hex, and high-hex identifier representations while preserving the existing toString() behavior.
  • When trace_id_128_bit is enabled:
    • keep x-datadog-trace-id as the low 64 bits in decimal;
    • add x-datadog-tags: _dd.p.tid=<high 64 bits in hex>;
    • send the full 128-bit hexadecimal ID in W3C traceparent, B3, and B3 multi headers;
    • store _dd.trace_id on RUM resource events as a 32-character lowercase hexadecimal string.
  • Keep span ID generation and session-consistent trace sampling unchanged; sampling still uses the low 64 bits.
  • Add restricted-CORS E2E coverage for the new x-datadog-tags header and the tracecontext-only fallback.

Enable it with:

DD_RUM.init({
  // ...
  enableExperimentalFeatures: ['trace_id_128_bit'],
})

Example from manual testing:

Representation Value
Full trace ID, 128-bit hex 6a6ca9f1000000000d5e267e2ee09948
High 64 bits, hex (_dd.p.tid) 6a6ca9f100000000
Low 64 bits, decimal (x-datadog-trace-id) 963249693698070856
Span ID, decimal 6901709716850828458

The full trace ID is the concatenation of the high 64-bit hex value and the low 64 bits converted to 16-character hexadecimal.

Playground

Screenshots:
Screenshot 2026-07-31 at 16 14 19

Screenshot 2026-07-31 at 16 14 30 Screenshot 2026-07-31 at 16 14 40

link of the example trace in DD

Test instructions

  1. Build and serve the local Browser SDK, then override the Playground SDK with the developer extension.

  2. Initialize RUM with:

    {
      "applicationId": "<application-id>",
      "clientToken": "<client-token>",
      "site": "datadoghq.com",
      "service": "browser-sdk-128bit-local",
      "allowedTracingUrls": ["https://datadoghq.dev"],
      "enableExperimentalFeatures": ["trace_id_128_bit"]
    }
  3. Trigger a traced fetch or XHR request.

  4. Verify that:

    • traceparent contains a non-zero 32-character trace ID;
    • x-datadog-tags contains _dd.p.tid matching the first 16 characters of traceparent;
    • x-datadog-trace-id remains a decimal representation of the low 64 bits;
    • the RUM resource event stores the same full trace ID as 32-character hexadecimal.
  5. For cross-origin Datadog propagation, allow x-datadog-tags in Access-Control-Allow-Headers; otherwise the browser preflight is expected to fail.

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated documentation and/or relevant AGENTS.md file

@BeltranBulbarellaDD

Copy link
Copy Markdown
Contributor Author

@codex pls review

@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 180.54 KiB 181.07 KiB +546 B +0.30%
Rum Profiler 8.43 KiB 8.43 KiB 0 B 0.00%
Rum Recorder 21.12 KiB 21.12 KiB 0 B 0.00%
Logs 57.05 KiB 57.09 KiB +38 B +0.07%
Rum Salesforce N/A 138.93 KiB N/A N/A N/A
Rum Slim 138.41 KiB 138.92 KiB +524 B +0.37%
Worker 22.96 KiB 22.96 KiB 0 B 0.00%
Rum Shopify N/A 200.64 KiB N/A N/A N/A
Rum-shopify Profiler N/A 8.43 KiB N/A N/A N/A
Rum-shopify Recorder N/A 3.72 KiB N/A N/A N/A

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 26b264f2d4

ℹ️ 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".

@datadog-official

datadog-official Bot commented Jul 31, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 62.50%
Overall Coverage: 77.13% (-0.01%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 26b264f | Docs | Datadog PR Page | Give us feedback!

@BeltranBulbarellaDD BeltranBulbarellaDD changed the title ✨ 128 bit trace ID ⚗️ Add 128-bit trace IDs for Browser RUM Jul 31, 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