MENU
instrumentation.js
Placed in the application root (or /src) like the Middleware, the instrumentation.js file integrates monitoring and logging tools into your application.
As it is an experimental feature, you need to enable it in the configuration file in order to use it.
The register function exported can be async. It is called once when a new Next.js server instance is initiated.
next.config.js:
instrumentation.ts:
next.config.js:
module.exports = {
experimental: {
instrumentationHook: true,
},
}instrumentation.ts:
import { registerOTel } from '@vercel/otel'
export function register() {
registerOTel('next-app')
}