rsnext/test/e2e/opentelemetry/instrumentation.ts
JJ Kasper eaa7606de1
Fix instrumentation with only pages (#62622)
This ensures we properly transpile `instrumentation.ts` when only
`pages` is being used as previously we were relying on the `app`
specific loaders which aren't configured when an `app` directory isn't
present. We regressed on this in
https://github.com/vercel/next.js/pull/60984 as it was working as
expected prior to this commit

x-ref: [slack
thread](https://vercel.slack.com/archives/C011GK1JUBA/p1709075846401649?thread_ts=1706643408.233909&cid=C011GK1JUBA)

Closes NEXT-2632
2024-02-28 11:38:39 +01:00

11 lines
426 B
TypeScript

export async function register() {
const { register: registerForTest } = await import('./instrumentation-test')
if (process.env.__NEXT_TEST_MODE) {
registerForTest()
} else if (process.env.NEXT_RUNTIME === 'nodejs') {
// We use this instrumentation for easier debugging with this test.
// We want this test to be executable with `pnpm next-with-deps`.
require('./instrumentation-node').register()
}
}