|
| 1 | +# Live Debugger Browser Monitoring |
| 2 | + |
| 3 | +Datadog Live Debugger enables you to capture function execution snapshots, evaluate conditions, and collect runtime data from your application without modifying source code. |
| 4 | + |
| 5 | +## Usage |
| 6 | + |
| 7 | +To start using the live debugger, add [`@datadog/browser-live-debugger`](https://www.npmjs.com/package/@datadog/browser-live-debugger) to your `package.json` file, then initialize it with: |
| 8 | + |
| 9 | +```javascript |
| 10 | +import { datadogLiveDebugger } from '@datadog/browser-live-debugger' |
| 11 | + |
| 12 | +datadogLiveDebugger.init({ |
| 13 | + clientToken: '<DATADOG_CLIENT_TOKEN>', |
| 14 | + site: '<DATADOG_SITE>', |
| 15 | + service: 'my-web-application', |
| 16 | + env: 'production', |
| 17 | + version: '1.0.0', |
| 18 | +}) |
| 19 | + |
| 20 | +// Add probes programmatically |
| 21 | +datadogLiveDebugger.addProbe({ |
| 22 | + id: 'probe-1', |
| 23 | + version: 0, |
| 24 | + type: 'LOG_PROBE', |
| 25 | + where: { typeName: 'MyClass', methodName: 'myMethod' }, |
| 26 | + template: 'Method executed with duration: {@duration}ms', |
| 27 | + segments: [ |
| 28 | + { str: 'Method executed with duration: ' }, |
| 29 | + { dsl: '@duration', json: { ref: '@duration' } }, |
| 30 | + { str: 'ms' }, |
| 31 | + ], |
| 32 | + captureSnapshot: true, |
| 33 | + capture: { maxReferenceDepth: 3 }, |
| 34 | + sampling: { snapshotsPerSecond: 5000 }, |
| 35 | + evaluateAt: 'EXIT', |
| 36 | +}) |
| 37 | +``` |
| 38 | + |
| 39 | +**Note**: Dynamic probe management from remote configuration will be added in a future release. |
| 40 | + |
| 41 | +## Integration with RUM |
| 42 | + |
| 43 | +The Live Debugger integrates seamlessly with Datadog RUM to provide enhanced context and correlation: |
| 44 | + |
| 45 | +```javascript |
| 46 | +import { datadogRum } from '@datadog/browser-rum' |
| 47 | +import { datadogLiveDebugger } from '@datadog/browser-live-debugger' |
| 48 | + |
| 49 | +// Initialize RUM first |
| 50 | +datadogRum.init({ |
| 51 | + applicationId: '<DATADOG_APPLICATION_ID>', |
| 52 | + clientToken: '<DATADOG_CLIENT_TOKEN>', |
| 53 | + site: '<DATADOG_SITE>', |
| 54 | + service: 'my-web-application', |
| 55 | + env: 'production', |
| 56 | +}) |
| 57 | + |
| 58 | +// Then initialize Live Debugger |
| 59 | +datadogLiveDebugger.init({ |
| 60 | + clientToken: '<DATADOG_CLIENT_TOKEN>', |
| 61 | + site: '<DATADOG_SITE>', |
| 62 | + service: 'my-web-application', |
| 63 | + env: 'production', |
| 64 | +}) |
| 65 | + |
| 66 | +// Add your probe configurations |
| 67 | +// datadogLiveDebugger.addProbe({ ... }) |
| 68 | +``` |
| 69 | + |
| 70 | +When both are initialized, debugger snapshots will automatically include RUM context (session, view, user action). |
| 71 | + |
| 72 | +## Features |
| 73 | + |
| 74 | +- **Dynamic Instrumentation**: Capture function entry/exit without code changes |
| 75 | +- **Conditional Breakpoints**: Evaluate conditions before capturing snapshots |
| 76 | +- **Template Expressions**: Evaluate custom messages with runtime context |
| 77 | +- **Rate Limiting**: Built-in sampling to prevent performance impact |
| 78 | +- **Stack Traces**: Automatic stack trace capture for debugging |
| 79 | +- **Variable Capture**: Deep capture of arguments, locals, and return values |
| 80 | + |
| 81 | +<!-- Note: all URLs should be absolute --> |
| 82 | + |
| 83 | +[1]: https://docs.datadoghq.com/dynamic_instrumentation/ |
0 commit comments