Skip to content

feat(esbuild): add DI worker bundling support#7440

Draft
watson wants to merge 1 commit intomasterfrom
watson/DEBUG-5156/support-di-with-esbuild
Draft

feat(esbuild): add DI worker bundling support#7440
watson wants to merge 1 commit intomasterfrom
watson/DEBUG-5156/support-di-with-esbuild

Conversation

@watson
Copy link
Collaborator

@watson watson commented Feb 5, 2026

What does this PR do?

Add support for bundling the Live Debugging (LD) / Dynamic Instrumentation (DI) worker when building applications with esbuild. This enables LD/DI features to work in bundled applications.

The plugin now:

  • Emits a separate worker bundle (dd-trace-debugger-worker.cjs) alongside the main application bundle
  • Patches the debugger module to reference the emitted worker
  • Patches the worker's dd-trace lookup to use global._ddtrace for bundler compatibility

Motivation

Without this, LD/DI would not work in a bundled application, as the worker thread would emit an error event when started, saying it couldn't find the worker file on disk.

Copy link
Collaborator Author

watson commented Feb 5, 2026

@watson watson added semver-minor debugger Dynamic Instrumentation & Live Debugger labels Feb 5, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2026

Overall package size

Self size: 4.57 MB
Deduped: 5.41 MB
No deduping: 5.41 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 2.0.6 | 81.92 kB | 813.08 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@codecov
Copy link

codecov bot commented Feb 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.41%. Comparing base (a2c60c1) to head (8467905).

Additional details and impacted files
@@                              Coverage Diff                               @@
##           watson/DEBUG-5156/esbuild-refactor-logging    #7440      +/-   ##
==============================================================================
- Coverage                                       80.44%   80.41%   -0.03%     
==============================================================================
  Files                                             730      732       +2     
  Lines                                           30929    31051     +122     
==============================================================================
+ Hits                                            24881    24970      +89     
- Misses                                           6048     6081      +33     
Flag Coverage Δ
aiguard-macos 39.07% <ø> (ø)
aiguard-ubuntu 39.11% <ø> (ø)
aiguard-windows 38.96% <ø> (ø)
apm-capabilities-tracing-macos 48.89% <ø> (ø)
apm-capabilities-tracing-ubuntu 48.89% <ø> (ø)
apm-capabilities-tracing-windows 48.62% <ø> (ø)
apm-integrations-child-process 38.57% <ø> (ø)
apm-integrations-couchbase-18 37.32% <ø> (ø)
apm-integrations-couchbase-eol 37.81% <ø> (ø)
apm-integrations-oracledb 38.00% <ø> (ø)
appsec-express 55.36% <ø> (-0.01%) ⬇️
appsec-fastify 51.99% <ø> (ø)
appsec-graphql 52.32% <ø> (ø)
appsec-kafka 44.64% <ø> (ø)
appsec-ldapjs 44.31% <ø> (ø)
appsec-lodash 43.99% <ø> (ø)
appsec-macos 58.48% <ø> (ø)
appsec-mongodb-core 49.19% <ø> (-0.01%) ⬇️
appsec-mongoose 49.88% <ø> (ø)
appsec-mysql 51.26% <ø> (ø)
appsec-node-serialize 43.50% <ø> (ø)
appsec-passport 48.10% <ø> (ø)
appsec-postgres 51.03% <ø> (-0.03%) ⬇️
appsec-sourcing 42.84% <ø> (ø)
appsec-template 43.67% <ø> (ø)
appsec-ubuntu 58.51% <ø> (ø)
appsec-windows 58.37% <ø> (+0.01%) ⬆️
instrumentations-instrumentation-bluebird 32.24% <ø> (ø)
instrumentations-instrumentation-body-parser 40.73% <ø> (ø)
instrumentations-instrumentation-child_process 37.88% <ø> (ø)
instrumentations-instrumentation-cookie-parser 34.50% <ø> (ø)
instrumentations-instrumentation-express 34.85% <ø> (ø)
instrumentations-instrumentation-express-mongo-sanitize 34.64% <ø> (ø)
instrumentations-instrumentation-express-session 40.41% <ø> (ø)
instrumentations-instrumentation-fs 31.84% <ø> (ø)
instrumentations-instrumentation-generic-pool 29.79% <ø> (ø)
instrumentations-instrumentation-http 39.62% <ø> (ø)
instrumentations-instrumentation-knex 32.24% <ø> (ø)
instrumentations-instrumentation-mongoose 33.61% <ø> (ø)
instrumentations-instrumentation-multer 40.47% <ø> (ø)
instrumentations-instrumentation-mysql2 38.26% <ø> (ø)
instrumentations-instrumentation-passport 40.77% <ø> (ø)
instrumentations-instrumentation-passport-http 40.74% <ø> (ø)
instrumentations-instrumentation-passport-local 40.74% <ø> (ø)
instrumentations-instrumentation-pg 37.78% <ø> (ø)
instrumentations-instrumentation-promise 32.17% <ø> (ø)
instrumentations-instrumentation-promise-js 32.18% <ø> (ø)
instrumentations-instrumentation-q 32.22% <ø> (ø)
instrumentations-instrumentation-url 32.14% <ø> (ø)
instrumentations-instrumentation-when 32.19% <ø> (ø)
llmobs-ai 41.41% <ø> (ø)
llmobs-anthropic 40.63% <ø> (ø)
llmobs-bedrock 39.51% <ø> (ø)
llmobs-google-genai 40.11% <ø> (ø)
llmobs-langchain 39.66% <ø> (ø)
llmobs-openai 44.46% <ø> (ø)
llmobs-vertex-ai 40.33% <ø> (-0.02%) ⬇️
platform-core 28.09% <ø> (ø)
platform-esbuild 31.49% <ø> (ø)
platform-instrumentations-misc 39.62% <ø> (ø)
platform-shimmer 34.83% <ø> (ø)
platform-unit-guardrails 30.37% <ø> (ø)
plugins-azure-event-hubs 22.64% <ø> (ø)
plugins-azure-service-bus 22.08% <ø> (?)
plugins-bullmq 43.56% <ø> (ø)
plugins-cassandra 38.04% <ø> (ø)
plugins-cookie 23.69% <ø> (ø)
plugins-cookie-parser 23.50% <ø> (ø)
plugins-crypto 22.88% <ø> (ø)
plugins-dd-trace-api 38.39% <ø> (ø)
plugins-express-mongo-sanitize 23.67% <ø> (ø)
plugins-express-session 23.46% <ø> (ø)
plugins-fastify 42.53% <ø> (ø)
plugins-fetch 38.60% <ø> (ø)
plugins-fs 38.67% <ø> (ø)
plugins-generic-pool 22.68% <ø> (ø)
plugins-google-cloud-pubsub 45.73% <ø> (ø)
plugins-grpc 41.29% <ø> (ø)
plugins-handlebars 23.71% <ø> (ø)
plugins-hapi 40.43% <ø> (ø)
plugins-hono 40.63% <ø> (ø)
plugins-ioredis 38.47% <ø> (ø)
plugins-knex 23.51% <ø> (ø)
plugins-ldapjs 21.28% <ø> (ø)
plugins-light-my-request 23.15% <ø> (ø)
plugins-limitd-client 32.39% <ø> (-0.16%) ⬇️
plugins-lodash 22.74% <ø> (ø)
plugins-mariadb 39.60% <ø> (ø)
plugins-memcached 38.20% <ø> (ø)
plugins-microgateway-core 39.44% <ø> (ø)
plugins-moleculer 40.84% <ø> (ø)
plugins-mongodb 39.55% <ø> (ø)
plugins-mongodb-core 39.12% <ø> (ø)
plugins-mongoose 39.18% <ø> (ø)
plugins-multer 23.46% <ø> (ø)
plugins-mysql 39.25% <ø> (ø)
plugins-mysql2 39.30% <ø> (?)
plugins-node-serialize 23.73% <ø> (ø)
plugins-opensearch 37.87% <ø> (ø)
plugins-passport-http 23.56% <ø> (ø)
plugins-postgres 35.71% <ø> (ø)
plugins-process 22.88% <ø> (ø)
plugins-pug 23.69% <ø> (ø)
plugins-redis 38.79% <ø> (?)
plugins-router 43.24% <ø> (-0.15%) ⬇️
plugins-sequelize 22.27% <ø> (ø)
plugins-test-and-upstream-amqp10 38.54% <ø> (ø)
plugins-test-and-upstream-amqplib 43.90% <ø> (ø)
plugins-test-and-upstream-apollo 39.32% <ø> (ø)
plugins-test-and-upstream-avsc 38.81% <ø> (ø)
plugins-test-and-upstream-bunyan 33.85% <ø> (ø)
plugins-test-and-upstream-connect 41.04% <ø> (ø)
plugins-test-and-upstream-graphql 40.22% <ø> (ø)
plugins-test-and-upstream-koa 40.69% <ø> (ø)
plugins-test-and-upstream-protobufjs 39.04% <ø> (ø)
plugins-test-and-upstream-rhea 44.15% <ø> (ø)
plugins-undici 39.39% <ø> (ø)
plugins-url 22.88% <ø> (ø)
plugins-valkey 38.12% <ø> (ø)
plugins-vm 22.88% <ø> (ø)
plugins-winston 34.26% <ø> (ø)
plugins-ws 40.75% <ø> (ø)
profiling-macos 40.44% <ø> (+0.37%) ⬆️
profiling-ubuntu 40.11% <ø> (ø)
profiling-windows 41.46% <ø> (ø)
serverless-azure-functions-client 22.38% <ø> (ø)
serverless-azure-functions-servicebus 22.38% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@datadog-datadog-prod-us1

This comment has been minimized.

@watson watson force-pushed the watson/DEBUG-5156/support-di-with-esbuild branch from fee4057 to b2bb277 Compare February 5, 2026 08:15
@watson watson force-pushed the watson/DEBUG-5156/esbuild-refactor-logging branch from 194df87 to 86646ea Compare February 5, 2026 08:15
@watson watson force-pushed the watson/DEBUG-5156/support-di-with-esbuild branch from b2bb277 to cf33a26 Compare February 5, 2026 08:16
@watson watson force-pushed the watson/DEBUG-5156/esbuild-refactor-logging branch from 86646ea to 7d2637c Compare February 5, 2026 08:16
@pr-commenter
Copy link

pr-commenter bot commented Feb 5, 2026

Benchmarks

Benchmark execution time: 2026-02-05 10:31:42

Comparing candidate commit f999386 in PR branch watson/DEBUG-5156/support-di-with-esbuild with baseline commit fe7175a in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 231 metrics, 29 unstable metrics.

@watson watson force-pushed the watson/DEBUG-5156/support-di-with-esbuild branch 2 times, most recently from e20aace to e03094e Compare February 5, 2026 09:22
@watson watson force-pushed the watson/DEBUG-5156/esbuild-refactor-logging branch from 7d2637c to 6c3e7ad Compare February 5, 2026 09:22
@watson watson force-pushed the watson/DEBUG-5156/support-di-with-esbuild branch from e03094e to 8467905 Compare February 5, 2026 09:51
@codecov
Copy link

codecov bot commented Feb 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.41%. Comparing base (fe7175a) to head (f999386).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #7440   +/-   ##
=======================================
  Coverage   80.41%   80.41%           
=======================================
  Files         732      732           
  Lines       31051    31051           
=======================================
  Hits        24971    24971           
  Misses       6080     6080           
Flag Coverage Δ
aiguard-macos 39.07% <ø> (-0.11%) ⬇️
aiguard-ubuntu 39.11% <ø> (-0.11%) ⬇️
aiguard-windows 38.96% <ø> (-0.11%) ⬇️
apm-capabilities-tracing-macos 48.85% <ø> (-0.05%) ⬇️
apm-capabilities-tracing-ubuntu 48.89% <ø> (ø)
apm-capabilities-tracing-windows 48.54% <ø> (-0.04%) ⬇️
apm-integrations-child-process 38.57% <ø> (-0.11%) ⬇️
apm-integrations-couchbase-18 37.32% <ø> (-0.10%) ⬇️
apm-integrations-couchbase-eol 37.81% <ø> (-0.25%) ⬇️
apm-integrations-oracledb 38.00% <ø> (-0.10%) ⬇️
appsec-express 55.37% <ø> (-0.08%) ⬇️
appsec-fastify 51.99% <ø> (-0.08%) ⬇️
appsec-graphql 52.32% <ø> (-0.07%) ⬇️
appsec-kafka 44.64% <ø> (-0.09%) ⬇️
appsec-ldapjs 44.31% <ø> (-0.09%) ⬇️
appsec-lodash 43.99% <ø> (-0.09%) ⬇️
appsec-macos 58.48% <ø> (-0.07%) ⬇️
appsec-mongodb-core 49.19% <ø> (-0.08%) ⬇️
appsec-mongoose 49.88% <ø> (-0.08%) ⬇️
appsec-mysql 51.26% <ø> (-0.08%) ⬇️
appsec-node-serialize 43.50% <ø> (-0.09%) ⬇️
appsec-passport 48.10% <ø> (-0.09%) ⬇️
appsec-postgres 51.03% <ø> (-0.10%) ⬇️
appsec-sourcing 42.84% <ø> (-0.09%) ⬇️
appsec-template 43.67% <ø> (-0.09%) ⬇️
appsec-ubuntu 58.51% <ø> (-0.07%) ⬇️
appsec-windows 58.37% <ø> (-0.05%) ⬇️
instrumentations-instrumentation-bluebird 32.24% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-body-parser 40.73% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-child_process 37.88% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-cookie-parser 34.50% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-express 34.85% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-express-mongo-sanitize 34.64% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-express-session 40.41% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-fs 31.84% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-generic-pool 29.79% <ø> (ø)
instrumentations-instrumentation-http 39.62% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-knex 32.24% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-mongoose 33.61% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-multer 40.47% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-mysql2 38.26% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-passport 40.77% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-passport-http 40.74% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-passport-local 40.74% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-pg 37.78% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-promise 32.17% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-promise-js 32.18% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-q 32.22% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-url 32.14% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-when 32.19% <ø> (-0.11%) ⬇️
llmobs-ai 41.41% <ø> (-0.10%) ⬇️
llmobs-anthropic 40.63% <ø> (-0.10%) ⬇️
llmobs-bedrock 39.51% <ø> (-0.09%) ⬇️
llmobs-google-genai 40.11% <ø> (-0.09%) ⬇️
llmobs-langchain 39.66% <ø> (-0.08%) ⬇️
llmobs-openai 44.46% <ø> (-0.09%) ⬇️
llmobs-vertex-ai 40.33% <ø> (-0.10%) ⬇️
platform-core 28.09% <ø> (ø)
platform-esbuild 31.49% <ø> (ø)
platform-instrumentations-misc 39.62% <ø> (ø)
platform-shimmer 34.83% <ø> (ø)
platform-unit-guardrails 30.37% <ø> (ø)
plugins-azure-event-hubs 22.64% <ø> (ø)
plugins-azure-service-bus 22.08% <ø> (ø)
plugins-bullmq 43.56% <ø> (-0.10%) ⬇️
plugins-cassandra 38.04% <ø> (-0.10%) ⬇️
plugins-cookie 23.69% <ø> (ø)
plugins-cookie-parser 23.50% <ø> (ø)
plugins-crypto 22.88% <ø> (ø)
plugins-dd-trace-api 38.39% <ø> (-0.11%) ⬇️
plugins-express-mongo-sanitize 23.67% <ø> (ø)
plugins-express-session 23.46% <ø> (ø)
plugins-fastify 42.53% <ø> (-0.10%) ⬇️
plugins-fetch 38.60% <ø> (-0.10%) ⬇️
plugins-fs 38.67% <ø> (-0.11%) ⬇️
plugins-generic-pool 22.68% <ø> (ø)
plugins-google-cloud-pubsub 45.73% <ø> (-0.09%) ⬇️
plugins-grpc 41.29% <ø> (-0.10%) ⬇️
plugins-handlebars 23.71% <ø> (ø)
plugins-hapi 40.43% <ø> (-0.10%) ⬇️
plugins-hono 40.63% <ø> (-0.10%) ⬇️
plugins-ioredis 38.47% <ø> (-0.11%) ⬇️
plugins-knex 23.51% <ø> (ø)
plugins-ldapjs 21.28% <ø> (ø)
plugins-light-my-request 23.15% <ø> (ø)
plugins-limitd-client 32.39% <ø> (-0.26%) ⬇️
plugins-lodash 22.74% <ø> (ø)
plugins-mariadb 39.60% <ø> (-0.10%) ⬇️
plugins-memcached 38.20% <ø> (-0.11%) ⬇️
plugins-microgateway-core 39.44% <ø> (-0.10%) ⬇️
plugins-moleculer 40.84% <ø> (-0.10%) ⬇️
plugins-mongodb 39.55% <ø> (-0.10%) ⬇️
plugins-mongodb-core 39.12% <ø> (-0.10%) ⬇️
plugins-mongoose 39.18% <ø> (-0.10%) ⬇️
plugins-multer 23.46% <ø> (ø)
plugins-mysql 39.25% <ø> (-0.11%) ⬇️
plugins-mysql2 39.30% <ø> (-0.10%) ⬇️
plugins-node-serialize 23.73% <ø> (ø)
plugins-opensearch 37.87% <ø> (-0.10%) ⬇️
plugins-passport-http 23.56% <ø> (ø)
plugins-postgres 35.78% <ø> (-0.02%) ⬇️
plugins-process 22.88% <ø> (ø)
plugins-pug 23.69% <ø> (ø)
plugins-redis 38.79% <ø> (-0.11%) ⬇️
plugins-router 43.24% <ø> (-0.10%) ⬇️
plugins-sequelize 22.27% <ø> (ø)
plugins-test-and-upstream-amqp10 38.39% <ø> (-0.26%) ⬇️
plugins-test-and-upstream-amqplib 43.90% <ø> (+0.04%) ⬆️
plugins-test-and-upstream-apollo 39.32% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-avsc 38.81% <ø> (-0.11%) ⬇️
plugins-test-and-upstream-bunyan 33.85% <ø> (-0.11%) ⬇️
plugins-test-and-upstream-connect 41.04% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-graphql 40.22% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-koa 40.69% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-protobufjs 39.04% <ø> (-0.11%) ⬇️
plugins-test-and-upstream-rhea 44.18% <ø> (-0.10%) ⬇️
plugins-undici 39.39% <ø> (-0.10%) ⬇️
plugins-url 22.88% <ø> (ø)
plugins-valkey 38.12% <ø> (-0.11%) ⬇️
plugins-vm 22.88% <ø> (ø)
plugins-winston 34.26% <ø> (-0.10%) ⬇️
plugins-ws 40.75% <ø> (-0.10%) ⬇️
profiling-macos 40.06% <ø> (-0.10%) ⬇️
profiling-ubuntu 40.11% <ø> (-0.10%) ⬇️
profiling-windows 41.46% <ø> (-0.10%) ⬇️
serverless-azure-functions-client 22.38% <ø> (ø)
serverless-azure-functions-eventhubs 22.38% <ø> (ø)
serverless-azure-functions-servicebus 22.38% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Base automatically changed from watson/DEBUG-5156/esbuild-refactor-logging to master February 5, 2026 10:16
Add support for bundling the Live Debugging (LD) / Dynamic
Instrumentation (DI) worker when building applications with esbuild.
This enables LD/DI features to work in bundled applications.

The plugin now:
- Emits a separate worker bundle (dd-trace-debugger-worker.cjs)
  alongside the main application bundle
- Patches the debugger module to reference the emitted worker
- Patches the worker's dd-trace lookup to use global._ddtrace for
  bundler compatibility
@watson watson force-pushed the watson/DEBUG-5156/support-di-with-esbuild branch from 8467905 to f999386 Compare February 5, 2026 10:17
@watson watson requested a review from Copilot February 5, 2026 10:32
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for bundling the Live Debugging (LD) / Dynamic Instrumentation (DI) worker when building applications with esbuild. This enables LD/DI features to function correctly in bundled applications where the worker thread would otherwise fail to find the worker file on disk.

Changes:

  • Emits a separate worker bundle (dd-trace-debugger-worker.cjs) alongside the main application bundle
  • Patches the debugger module to reference the emitted worker bundle instead of the original source location
  • Patches the worker's trace/span lookup to use global._ddtrace for bundler compatibility

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/datadog-esbuild/index.js Adds core implementation: debugger index transformation, worker bundle building logic, and helper functions for output directory resolution
integration-tests/esbuild/index.spec.js Adds cleanup for the new worker bundle file in existing tests
integration-tests/esbuild/build-and-test-debugger-worker.js New comprehensive test file that verifies worker bundle emission, content validation, and runtime behavior with DI enabled

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

debugger Dynamic Instrumentation & Live Debugger semver-minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant