Repository navigation
✨ [RUM-20014] attach trace/span ids to manual resources via internal options - #5279
BeltranBulbarellaDD wants to merge 10 commits into
Conversation
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.
Bundles Sizes Evolution
|
🎉 All green!🧪 All tests passed 🔁 Datadog re-ran 🎯 Code Coverage (details) 🔗 Commit SHA: 8884831 | Docs | View more details | Give us feedback! |
|
@codex pls review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
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.
There was a problem hiding this comment.
💡 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".
There was a problem hiding this comment.
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.
🤖 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.
There was a problem hiding this comment.
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.
🤖 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.
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_psrfrom the attributes map.Per the discussion, the ids are passed as typed
@internaloptions rather than reserved keys incontext, which stays reserved for user-defined attributes.Jira: RUM-20014
Changes
ResourceOptionsandResourceStopOptionsget@internaltraceId,spanIdandrulePsroptions, shared through a non-exportedResourceOptionsBase(same pattern asFetchContextBase).trackManualResourcesmerges start and stop values (stop wins) and sets the event_ddonly when bothtraceIdandspanIdare set.rulePsris added only alongside them.traceIdandspanIdmust be non-empty strings andrulePsra number, otherwise they are ignored (wrapper SDKs call through untyped JS interop).startResource/stopResourcein the public API forwardtraceId,spanIdandrulePsrto the tracker.contextis passed through untouched.rulePsrand 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 intest/e2e/scenario/rum/resources.scenario.ts.yarn typecheck, eslint andyarn buildpass locally.Checklist