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

Instrumentation.ts issues #287

Open
shawnmclean opened this issue Nov 27, 2024 · 0 comments
Open

Instrumentation.ts issues #287

shawnmclean opened this issue Nov 27, 2024 · 0 comments

Comments

@shawnmclean
Copy link

I'm trying to use this package when following this open telemetry example: https://nextjs.org/docs/app/building-your-application/optimizing/open-telemetry

When I swap out process.env.NEXT_RUNTIME for env.NEXT_RUNTIME with all the configs and console logs, it seems to try importing the node package and throws a module resolution issue.

import { env } from "./env";

export async function register() {
  console.log("env", env.NEXT_RUNTIME);
  console.log("process.env", process.env.NEXT_RUNTIME);
  if (env.NEXT_RUNTIME === "nodejs") {
    console.log("instrumentation registering");
    await import("./instrumentation.node");
  }
}

This is a weird issue because all the console logs work well during next dev. They write out nodejs. But when I load a route, I don't see the logs but an error is thrown.

This error is not thrown if I change the check to process.env.NEXT_RUNTIME === 'nodejs'.

I have it wired up to next.config too with the jiti.

Is next doing some funny stuff here why its not working with your library?

shawnmclean added a commit to shawnmclean/sovoli that referenced this issue Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant