Skip to content

Add Live Debugger package#4448

Closed
watson wants to merge 1 commit intoDataDog:mainfrom
watson:watson/DEBUG-5296/add-live-debugger
Closed

Add Live Debugger package#4448
watson wants to merge 1 commit intoDataDog:mainfrom
watson:watson/DEBUG-5296/add-live-debugger

Conversation

@watson
Copy link
Copy Markdown
Collaborator

@watson watson commented Apr 7, 2026

Motivation

Introduce the @datadog/browser-debugger package to enable Live Debugger in browser applications. This gives frontend developers the ability to add log probes to running applications, evaluate conditions, and inspect runtime state — all without redeploying or modifying source code.

Changes

New package: packages/debugger

A new @datadog/browser-debugger package that provides the full probe execution pipeline:

  • domain/api.ts — Core instrumentation hooks (onEntry, onReturn, onThrow) that execute probes when instrumented functions are called, including condition evaluation, snapshot capture, template message rendering, and rate limiting.
  • domain/probes.ts — Probe lifecycle management (add, remove, clear) with per-probe and global snapshot rate limiting. Compiles probe conditions and template segments on registration.
  • domain/capture.ts — Deep value capture for arguments, locals, return values, and thrown errors with configurable reference depth, collection size limits, and string length limits.
  • domain/expression.ts — Expression compiler that parses JSON expression trees (comparisons, logical operators, member access, string operations, etc.) into executable functions.
  • domain/condition.ts — Probe condition evaluator that compiles and caches condition expressions.
  • domain/template.ts — Template segment compiler and evaluator for rendering dynamic probe messages with runtime context.
  • domain/stacktrace.ts — Stack trace capture and parsing from Error objects.
  • domain/deliveryApi.ts — Polling-based probe delivery client that fetches probe updates/deletions from the Delivery API using a cursor for incremental sync.
  • transport/startDebuggerBatch.ts — Transport layer that reuses @datadog/browser-core's batch/flush infrastructure to send debugger snapshots to the logs intake.
  • entries/main.ts — Public API surface (datadogLiveDebugger.init(), addProbe(), removeProbe(), clearProbes(), getProbes()). Exposes $dd_entry/$dd_return/$dd_throw hooks on globalThis for instrumented code.

Changes to @datadog/browser-core

  • Added 'dd_debugger' as a valid source in configuration and transport types.
  • Exported computeTransportConfiguration and the Batch type so the debugger package can create its own transport.

Sandbox / Tooling

  • sandbox/debugger/ — Local testing sandbox with an HTML test page, sample probes, and a Remote Config proxy server for end-to-end manual testing against the Delivery API.
  • test/apps/instrumentation-overhead/ — Webpack test app for measuring instrumentation overhead.
  • test/performance/ — New instrumentation-overhead performance benchmark scenario.
  • Updated scripts/build/build-test-apps.ts and scripts/dev-server/lib/server.ts to include the new test app.
  • Added debugger entry point to ESLint side-effects allowlist.

Test instructions

  1. Unit tests: Run yarn test:unit --spec packages/debugger/src/domain/api.spec.ts (and similarly for capture.spec.ts, condition.spec.ts, deliveryApi.spec.ts, expression.spec.ts, probes.spec.ts, stacktrace.spec.ts, template.spec.ts) — ~2,930 lines of spec coverage across 8 spec files.
  2. Sandbox testing: See sandbox/debugger/rc-proxy/QUICKSTART.md for local end-to-end testing with the Delivery API proxy.
  3. Performance testing: yarn build:apps && yarn test:performance to run the instrumentation overhead benchmark.

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

Introduce the browser debugger SDK and probe execution pipeline so
browser code can evaluate conditions, capture snapshots, and render
probe messages at runtime. Add Delivery API polling plus sandbox and
performance tooling to support probe delivery and testing.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@watson watson closed this Apr 7, 2026
@watson watson deleted the watson/DEBUG-5296/add-live-debugger branch April 7, 2026 08:48
@github-actions github-actions bot locked and limited conversation to collaborators Apr 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant