Repository navigation
Conversation
Bundles Sizes Evolution
|
🎉 All green!🧪 All tests passed 🔁 Datadog re-ran 🎯 Code Coverage (details) 🔗 Commit SHA: d5d032b | Docs | View more details | Give us feedback! |
…wn rate Core's user context tests need the same mock as Logs' session context tests. Moved as is, the sessionContext spec passes 6/6.
The Logs plugin reads the user and account from RUM's getUser() and getAccount(), with the same rules as today. The hooks move into startUserContextHook and startAccountContextHook, which startUserContext and startAccountContext call with their own contexts. The anonymous_id lookup passes the configured rate, which each SDK's own session manager already defaults to, so RUM and standalone Logs don't change. The 4 new tests failed first, and the rate test failed until the rate was passed.
…source The Logs plugin reads correlation ids from RUM's getInternalContext() and consent from RUM's isTrackingConsentGranted(). startRUMInternalContext takes the lookup, and startLogs passes today's window.DD_RUM one. startTrackingConsentContext only needs isGranted(). The new test failed first, reading the global instead of the given lookup.
getInternalContextFromRumGlobal had one caller and only guarded an optional call. getRUMInternalContextFromGlobal now ends with an optional call instead, with the same behavior. Proved by rumInternalContext.spec.ts (7/7), which goes red when the lookup ignores DD_RUM_SYNTHETICS, plus the full unit suite (5605/5605), typecheck and lint.
The Logs plugin reads the global context from RUM's getGlobalContext(), so customers set it once for both. The hook moves into startGlobalContextHook, which startGlobalContext calls with its own context, so RUM and standalone Logs don't change. The new test failed first.
mormubis
force-pushed
the
adlrb/RUM-19971-logs-rum-contexts
branch
from
December 3, 2026 16:08
8856028 to
d5d032b
Compare
1 of 5 tasks
This branch has not been deployed
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.
Motivation
The Logs plugin from the RFC takes the user, the account, the global context, the correlation ids and the consent from RUM, instead of its own contexts,
window.DD_RUMand its own consent. A log should look the same in both modes.This is the third of 4 stacked PRs. It lets the contexts take those sources, with no change for
datadogLogs.init()or for RUM.Stacked on #5338.
Refs: RUM-19971
Changes
startUserContext()andstartAccountContext()in core now callstartUserContextHook()andstartAccountContextHook(), which take a getter. The plugin will pass RUM'sgetUser()andgetAccount(), with today's rules:anonymous_idfrom the session, empty contexts skipped, and an account needs anid.startGlobalContext()gets the same split withstartGlobalContextHook(). The plugin will pass RUM'sgetGlobalContext()withuseContextNamespaceset tofalse, so RUM's global context lands at the top level of the log, like Logs' own today.The
anonymous_idlookup passesconfiguration.sessionSampleRate, like the session context in #5338. RUM and Logs build their session manager from that same configuration, so their rate doesn't change.startRUMInternalContext()takes thegetInternalContextlookup.startLogs()passesgetRUMInternalContextFromGlobal(), today'swindow.DD_RUMlookup, and the plugin will pass RUM's.startTrackingConsentContext()only needsisGranted(), so the plugin can passisTrackingConsentGranted().The mock from #5338 that samples at its own rate moves to core's test helpers, so the user context tests can use it too.
Bundle size:
rumandrum_slimgrow by 101 B (rumgoes from 195.70 KiB to 195.80 KiB).logsgrows by 47 B (60.41 KiB to 60.46 KiB).Test instructions
The same page sends the same logs on #5338's branch and on this one, apart from ids and dates:
Expected output, on both branches:
Then
yarn dev-server stopandrm sandbox/test-logs-payload.html.Unit tests:
Checklist