Open
Description
Tracer Version(s)
5.42.0
Node.js Version(s)
22.14.0
Bug Report
I'm initialising dd-trace from the instrumentaion.ts
file of my NextJS app. I noticed nothing happened within the next plugin. For instance the following code didn't log anything:
tracer.use('next', {
service: 'my-app',
hooks: {
request: (span, request, response) => {
console.log({ span, request, response });
},
},
});
So I tried to understand what was happening, and I added a log in node_modules/dd-trace/packages/dd-trace/src/plugin_manager.js
:
loadPlugin (name) {
const Plugin = pluginClasses[name]
console.log("LOADPLUGIN", name, Plugin);
This log indicates classes for other plugins, but not for the next plugin:
LOADPLUGIN dns [class DNSPlugin extends CompositePlugin]
LOADPLUGIN net [class NetPlugin extends Plugin]
LOADPLUGIN next undefined
I don't know why, but the result is that the plugin's hook is never called.
Reproduction Code
In instrumentation.ts
of a NextJS 15.2.1 app:
import trace from 'dd-trace';
export async function register() {
if (process.env.NEXT_RUNTIME === 'nodejs') {
const tracer = trace.init({
logInjection: true,
startupLogs: true,
hostname: process.env.STATSD_HOST,
port: process.env.STATSD_PORT,
runtimeMetrics: true,
env: 'staging',
});
tracer.use('next', {
service: 'my-app',
hooks: {
request: (span, request, response) => {
console.log({ span, request, response });
},
},
});
}
}
Error Logs
No response
Tracer Config
{
logInjection: true,
startupLogs: true,
hostname: process.env.STATSD_HOST,
port: process.env.STATSD_PORT,
runtimeMetrics: true,
env: 'staging',
}
Operating System
Darwin Kernel Version 24.3.0
Bundling
Next.js