Skip to content

Commit

Permalink
OpenTelemetry: clarify Edge runtime support (#61338)
Browse files Browse the repository at this point in the history
  • Loading branch information
dvoytenko committed Jan 29, 2024
1 parent 6eb2c24 commit 1862b8a
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ npm install @opentelemetry/sdk-node @opentelemetry/resources @opentelemetry/sema
```

Now you can initialize `NodeSDK` in your `instrumentation.ts`.
OpenTelemetry APIs are not compatible with edge runtime, so you need to make sure that you are importing them only when `process.env.NEXT_RUNTIME === 'nodejs'`. We recommend creating a new file `instrumentation.node.ts` which you conditionally import only when using node:
Unlike `@vercel/otel`, `NodeSDK` is not compatible with edge runtime, so you need to make sure that you are importing them only when `process.env.NEXT_RUNTIME === 'nodejs'`. We recommend creating a new file `instrumentation.node.ts` which you conditionally import only when using node:

```ts filename="instrumentation.ts" switcher
export async function register() {
Expand Down Expand Up @@ -144,7 +144,7 @@ const sdk = new NodeSDK({
sdk.start()
```

Doing this is equivalent to using `@vercel/otel`, but it's possible to modify and extend some features that are not exposed by the `@vercel/otel`.
Doing this is equivalent to using `@vercel/otel`, but it's possible to modify and extend some features that are not exposed by the `@vercel/otel`. If edge runtime support is necessary, you will have to use `@vercel/otel`.

## Testing your instrumentation

Expand Down

0 comments on commit 1862b8a

Please sign in to comment.