Unverified Commit ababa1b3 authored by Swarnava Sengupta's avatar Swarnava Sengupta Committed by GitHub

docs: clarify async instrumentation register request (#90039)

Explicitly document that Next.js waits for an async instrumentation
register function to complete before handling incoming requests, and
align wording between the guide and API reference.

---------
Co-authored-by: 's avatarCursor <cursoragent@cursor.com>
Co-authored-by: 's avatarJoseph <joseph.chamochumbi@vercel.com>
parent 80e849e1
...@@ -16,7 +16,7 @@ Instrumentation is the process of using code to integrate monitoring and logging ...@@ -16,7 +16,7 @@ Instrumentation is the process of using code to integrate monitoring and logging
To set up instrumentation, create `instrumentation.ts|js` file in the **root directory** of your project (or inside the [`src`](/docs/app/api-reference/file-conventions/src-folder) folder if using one). To set up instrumentation, create `instrumentation.ts|js` file in the **root directory** of your project (or inside the [`src`](/docs/app/api-reference/file-conventions/src-folder) folder if using one).
Then, export a `register` function in the file. This function will be called **once** when a new Next.js server instance is initiated. Then, export a `register` function in the file. This function will be called **once** when a new Next.js server instance is initiated, and must complete before the server is ready to handle requests.
For example, to use Next.js with [OpenTelemetry](https://opentelemetry.io/) and [@vercel/otel](https://vercel.com/docs/observability/otel-overview): For example, to use Next.js with [OpenTelemetry](https://opentelemetry.io/) and [@vercel/otel](https://vercel.com/docs/observability/otel-overview):
......
...@@ -15,7 +15,7 @@ To use it, place the file in the **root** of your application or inside a [`src` ...@@ -15,7 +15,7 @@ To use it, place the file in the **root** of your application or inside a [`src`
### `register` (optional) ### `register` (optional)
The file exports a `register` function that is called **once** when a new Next.js server instance is initiated. `register` can be an async function. The file exports a `register` function that is called **once** when a new Next.js server instance is initiated, and must complete before the server is ready to handle requests. `register` can be an async function.
```ts filename="instrumentation.ts" switcher ```ts filename="instrumentation.ts" switcher
import { registerOTel } from '@vercel/otel' import { registerOTel } from '@vercel/otel'
......
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