elastic / elastic/elastic-otel-node
edot doc: add Next.js example
- Dominant language
- JavaScript
- Stars
- 12
- Forks
- 22
- Avg merge
- 16h 54m
- Merged PRs (30d)
- 5
Description
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):
```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.
Contributor guide
Assessment
This issue has not been assessed yet.