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

edot doc: add Next.js example #607

Open
trentm opened this issue Feb 12, 2025 · 1 comment
Open

edot doc: add Next.js example #607

trentm opened this issue Feb 12, 2025 · 1 comment

Comments

@trentm
Copy link
Member

trentm commented Feb 12, 2025

We should have examples/nextjs and/or Next.js doc section in the EDOT Node.js docs.
Jessica has an example we can use or crib from.
IIUC, the core of it is using Next.js automatic loading of instrumentation.{ts,js} (https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation) to start the SDK. Something roughly like:

instrumentation.ts or src/instrumentation.ts (or .js):

export async function register() {
  if (process.env.NEXT_RUNTIME === 'nodejs') {
      await import('@elastic/opentelemetry-node');
  }
}

Compare to similar usage of Vercel's own @vercel/otel described at: https://nextjs.org/docs/app/building-your-application/optimizing/open-telemetry
I'm curious whether the instrumentation compares favourably. E.g. does the Next.js by default send spans with route info to any registered global TracerProvider? Etc.

@JessicaGarson
Copy link

I went ahead and made this repository public: https://github.com/JessicaGarson/otel-nextjs-elastic/

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

2 participants