Skip to content

[BUG]: Next plugin not loaded #5430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ganlhi opened this issue Mar 18, 2025 · 0 comments
Open

[BUG]: Next plugin not loaded #5430

ganlhi opened this issue Mar 18, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@ganlhi
Copy link

ganlhi commented Mar 18, 2025

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

@ganlhi ganlhi added the bug Something isn't working label Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant