Unverified Commit 13c205ff authored by Delba de Oliveira's avatar Delba de Oliveira Committed by GitHub

[Docs] Add note about adding the instrumentation file inside 'src' (#51415)

The instrumentation.js should be placed in the root, or inside the 'src' folder if one exists
parent a3ef99ac
......@@ -35,7 +35,7 @@ To get started, you must install `@vercel/otel`:
npm install @vercel/otel
```
Next, create a custom [`instrumentation.ts`](/docs/pages/building-your-application/optimizing/instrumentation) (or `.js`) file in the **root directory** of the project:
Next, create a custom [`instrumentation.ts`](/docs/pages/building-your-application/optimizing/instrumentation) (or `.js`) file in the **root directory** of the project (or inside `src` folder if using one):
```ts filename="your-project/instrumentation.ts" switcher
import { registerOTel } from '@vercel/otel'
......@@ -55,7 +55,7 @@ export function register() {
> **Good to know**
>
> - The `instrumentation` file should be in the root of your project and not the `app` or `pages` directory.
> - The `instrumentation` file should be in the root of your project and not inside the `app` or `pages` directory. If you're using the `src` folder, then place the file inside `src` alongside `pages` and `app`.
> - If you use the [`pagesExtension` config option](/docs/pages/api-reference/next-config-js/pageExtensions) to add a suffix, you will also need to update the `instrumentation` filename to match.
> - We have created a basic [with-opentelemetry](https://github.com/vercel/next.js/tree/canary/examples/with-opentelemetry) example that you can use.
......
......@@ -3,13 +3,12 @@ title: Instrumentation
description: Learn how to use instrumentation to run code at server startup in your Next.js app
---
> **Good to know**: This feature is **experimental**. To use it, you must explicitly opt in by defining `experimental.instrumentationHook = true;` in your `next.config.js`.
If you export a function named `register` from a `instrumentation.ts` (or `.js`) file in the **root directory** of your project, we will call that function whenever a new Next.js server instance is bootstrapped.
If you export a function named `register` from a `instrumentation.ts` (or `.js`) file in the **root directory** of your project (or inside the `src` folder if using one), we will call that function whenever a new Next.js server instance is bootstrapped.
> **Good to know**
>
> - The `instrumentation` file should be in the root of your project and not the `app` or `pages` directory.
> - This feature is **experimental**. To use it, you must explicitly opt in by defining `experimental.instrumentationHook = true;` in your `next.config.js`.
> - The `instrumentation` file should be in the root of your project and not inside the `app` or `pages` directory. If you're using the `src` folder, then place the file inside `src` alongside `pages` and `app`.
> - If you use the [`pagesExtension` config option](/docs/pages/api-reference/next-config-js/pageExtensions) to add a suffix, you will also need to update the `instrumentation` filename to match.
> - We have created a basic [with-opentelemetry](https://github.com/vercel/next.js/tree/canary/examples/with-opentelemetry) example that you can use.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment