Skip to content

✨ [RUM-20014] attach trace/span ids to manual resources via internal options - #5279

Open
BeltranBulbarellaDD wants to merge 10 commits into
mainfrom
beltran.bulbarella/manual-resources-attach-trace-span-ids-bbd05c49
Open

BeltranBulbarellaDD wants to merge 10 commits into
mainfrom
beltran.bulbarella/manual-resources-attach-trace-span-ids-bbd05c49

Conversation

@BeltranBulbarellaDD

@BeltranBulbarellaDD BeltranBulbarellaDD commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Manual resources (startResource/stopResource) always sent an empty _dd, so trace and span ids were dropped and resources from wrapper SDKs no longer linked to APM traces. Flutter web regressed after moving to the manual API (dd-sdk-flutter #957), and Unity WebGL has the same gap. The mobile SDKs already read _dd.trace_id / _dd.span_id / _dd.rule_psr from the attributes map.

Per the discussion, the ids are passed as typed @internal options rather than reserved keys in context, which stays reserved for user-defined attributes.

Jira: RUM-20014

Changes

  • ResourceOptions and ResourceStopOptions get @internal traceId, spanId and rulePsr options, shared through a non-exported ResourceOptionsBase (same pattern as FetchContextBase).
  • trackManualResources merges start and stop values (stop wins) and sets the event _dd only when both traceId and spanId are set. rulePsr is added only alongside them. traceId and spanId must be non-empty strings and rulePsr a number, otherwise they are ignored (wrapper SDKs call through untyped JS interop).
  • startResource/stopResource in the public API forward traceId, spanId and rulePsr to the tracker.
  • context is passed through untouched.
  • Automatic fetch/XHR resources are unchanged.
  • Unit tests cover ids at start, ids at stop, stop precedence, partial ids, rulePsr and wrong-typed values, plus the public API forwarding. An E2E scenario verifies manual resource trace ids.

Test instructions

yarn test:unit packages/browser-rum-core/src/domain/resource/trackManualResources.spec.ts. The E2E scenario is in test/e2e/scenario/rum/resources.scenario.ts. yarn typecheck, eslint and yarn build pass locally.

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

Read reserved _dd.trace_id/_dd.span_id context keys in startResource/stopResource, strip them from context and set them on the event _dd when both are strings.
@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum Salesforce 192.54 KiB 192.67 KiB +127 B +0.06% ✅
Rum 192.52 KiB 192.65 KiB +127 B +0.06% ✅
Rum Profiler 8.17 KiB 8.17 KiB 0 B 0.00% ✅
Rum Salesforce Profiler 8.17 KiB 8.17 KiB 0 B 0.00% ✅
Rum Salesforce Recorder 32.62 KiB 32.62 KiB 0 B 0.00% ✅
Rum Recorder 32.62 KiB 32.62 KiB 0 B 0.00% ✅
Logs 60.26 KiB 60.26 KiB 0 B 0.00% ✅
Rum Slim 148.45 KiB 148.57 KiB +127 B +0.08% ✅
Worker 24.23 KiB 24.23 KiB 0 B 0.00% ✅
Rum Shopify 223.58 KiB 223.71 KiB +127 B +0.06% ✅
Rum Shopify Profiler 8.17 KiB 8.17 KiB 0 B 0.00% ✅
Rum Shopify Recorder 4.85 KiB 4.85 KiB 0 B 0.00% ✅

@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Pipelines  Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🔁 Datadog re-ran unit-bs: [safari-desktop] after it failed. The re-run passed. View in Datadog

🎯 Code Coverage (details)
• Patch Coverage: 100.00%
• Overall Coverage: 78.11% (+0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 8884831 | Docs | View more details | Give us feedback!

@BeltranBulbarellaDD

Copy link
Copy Markdown
Contributor Author

@codex pls review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T19:36:00.849860Z 8884831 New commits
🔒 Security Review ✅ Completed 2026-11-17T19:37:40.038827Z 8884831 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 1a745b216b

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

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 1a745b216b

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Read _dd.rule_psr from manual resource context, always strip it, and set it on _dd when it is a number and both trace ids are present.
refs: RUM-20014

Replace the reserved _dd.* context keys with @internal traceId, spanId and
rulePsr options, shared through ResourceOptionsBase.
@BeltranBulbarellaDD BeltranBulbarellaDD changed the title ✨ attach trace/span ids to manual resources ✨ [RUM-20014] attach trace/span ids to manual resources via internal options Nov 17, 2026
@BeltranBulbarellaDD
BeltranBulbarellaDD marked this pull request as ready for review November 17, 2026 11:53
@BeltranBulbarellaDD
BeltranBulbarellaDD requested a review from a team as a code owner November 17, 2026 11:53

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dbc3b8a4da

ℹ️ 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-prod-us1-5 datadog-prod-us1-5 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: FAIL

The public API handlers for startResource/stopResource in rumPublicApi.ts drop traceId, spanId, and rulePsr when reconstructing the options object, so manual resources never carry APM trace metadata and the _dd field remains empty. All three fields must be forwarded through both handlers to make APM correlation functional.

Open Bits AI session

🤖 Bits Code Review · Commit dbc3b8a

refs: RUM-20014

startResource/stopResource rebuilt their options without traceId, spanId and
rulePsr, so they never reached trackManualResources. Forward them and only set
_dd when the ids are strings and rulePsr is a number, since wrapper SDKs call
through untyped JS interop.

@datadog-prod-us1-5 datadog-prod-us1-5 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: PASS

More details

Manual resources can carry internal trace/span IDs and sampling rates into _dd, with stop options taking precedence and user context preserved. The latest commit fixes the public API forwarding defect and adds runtime type checks for the metadata; no review findings remain open.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 5c022f3

refs: RUM-20014

Replace the traceId/spanId/rulePsr internal options with a single tracing
object and map it directly to _dd, dropping the runtime type guards.

This branch has not been deployed

No deployments
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.

3 participants