♻️ Move global monitor functions to js-core - #4986
Draft
BenoitZugmeyer wants to merge 2 commits into
Draft
Conversation
|
✅ All CI checks and tests passed. 🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 7c4464d | Docs | View more details | Give us feedback! |
BenoitZugmeyer
force-pushed
the
benoit/move-monitor-to-js-core
branch
from
August 26, 2026 09:53
e8af479 to
7c4464d
Compare
Bundles Sizes Evolution
|
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
As more utilities move from
browser-coretojs-core(starting withhttpRequest), several shared functions need access to themonitorerror-collection helpers. These are used pervasively as bare globals — passed toaddEventListener,setTimeout, Observable subscriptions, etc. — so they must remain globally available rather than threaded through every call site. Hosting the global monitor injs-corelets shared code there use it directly and unblocks further utility migrations.When several SDKs share the same
js-coremodule instance, only the first SDK to init receives internal-error telemetry from the global monitor (first-wins). This is a deliberate trade-off for simplicity over per-SDK attribution, which can be revisited in the future.Changes
@datadog/js-core/monitor(monitor,callMonitored,monitored,monitorError) alongside the existingcreateMonitorfactory.startMonitorErrorCollection(cb)(first-wins, returnsfalseif already claimed) andstopMonitorErrorCollection()(production detach path) to manage the error-collection sink.browser-core; all consumers (browser-core internals, browser-rum-core, browser-rum, browser-logs, and framework integrations) now import monitor helpers directly from@datadog/js-core/monitor.monitorDisplayfrom@datadog/js-core/monitorso tests can spy on the monitor's debug output (the global monitor no longer shares a display instance withbrowser-core).startMonitorErrorCollectionJSDoc.Test instructions
yarn dev), load the SDK and trigger an internal error (e.g. misconfigure an endpoint so a monitored callback throws). Confirm the error is captured in telemetry and no uncaught exception surfaces to the page.DD_RUM._setDebug(true)/DD_LOGS._setDebug(true)) and trigger a monitored error; confirm a[MONITOR]error is logged to the console with theDatadog SDK:prefix.Checklist