Skip to content
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

Fix Next.js 14.2.x incompatibility #1141

Open
luismiramirez opened this issue Oct 22, 2024 · 2 comments
Open

Fix Next.js 14.2.x incompatibility #1141

luismiramirez opened this issue Oct 22, 2024 · 2 comments

Comments

@luismiramirez
Copy link
Member

luismiramirez commented Oct 22, 2024

Next.js 14.2.x applications don't report spans to the agent.

When configured following the docs, the agent starts, and host metrics work. However, Next.js spans aren't reported, and the AppSignal OpenTelemetry tracer isn't able to identify the current span nor create new ones.

Next.js built-in instrumentation works as the emitted spans can be seen when adding a ConsoleSpanExporter()

instrumentation.ts file to output spans in console and to run AppSignal at the same time.

export async function register() {
  if (process.env.NEXT_RUNTIME === "nodejs") {
    try {
      const { NodeTracerProvider } = require("@opentelemetry/sdk-trace-node");
      const { BatchSpanProcessor } = require("@opentelemetry/sdk-trace-base");
      const { ConsoleSpanExporter } = require("@opentelemetry/sdk-trace-base");

      const provider = new NodeTracerProvider();

      // Just for testing, let's output to console
      provider.addSpanProcessor(new BatchSpanProcessor(new ConsoleSpanExporter()));

      provider.register();
      console.log("Tracer provider registered");

      require("./appsignal.cjs");
    } catch (error) {
      console.error("Failed to initialize OpenTelemetry:", error);
    }
  }
}

Next.js 13.x, 14.1.x, and 15 work.

Internal link

@shairyar
Copy link
Member

@backlog-helper
Copy link

backlog-helper bot commented Nov 6, 2024

  • This issue has not had any activity in 14 days. Please provide a status update if it is still relevant. Closed it if it is no longer relevant. Or move it to another column if it's blocked or requires another look at it. - (More info)

This is a message from the daily scheduled checks.

New issue guide | Backlog management | Rules | Feedback

@luismiramirez luismiramirez removed their assignment Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants