dd-trace-js
dd-trace-js copied to clipboard
esbuild bundled express application does not pick up express integration
Expected behaviour
The express integration should be registered
Actual behaviour
The express integration is not registered
Steps to reproduce
Followed the steps here https://docs.datadoghq.com/tracing/setup_overview/setup/nodejs/?tabs=containers#typescript-and-bundlers
For TS and bundlers. Built the app by calling:
esbuild src/server.ts --bundle --platform=node --target=node14.18.2 --outfile=dist/server.js --sourcemap",
Ran with:
DD_TRACE_STARTUP_LOGS=true yarn start
The integrations listed are only fs and http2. This was tested on the latest version (2.10) as well as (2.6)
building the app with tsc does not give the same problem.
Environment
- Operation system: Mac OSX, GAE
- Node.js version:
- node14.18.2
- Tracer version: 2.6, 2.10
- Agent version: N/A
- Relevant library versions:
Should also note that adding --external:express does allow dd-trace to add the express integration
Right now we only support libraries that are not included in the bundle, so the ones marked as external as you mentioned above. We will eventually work on improving our support for bundlers, but this is unlikely to happen short-term. In the meantime, we recommend using a configuration that will keep all of node_modules external to completely avoid all instrumentation issues. It looks like the esbuild-node-externals would do the trick.
I've added official esbuild support to dd-trace since this issue was written. If you're still having this issue please try out the plugin: https://docs.datadoghq.com/tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/#esbuild-support
I'll close this for now assuming it works. If it doesn't please tag me and reopen.