# Next.js already traces your requests. Here's how to export them with OpenTelemetry.

[Sentry](https://yomu.fyi/company/sentry) · Kyle Tryon · Jun 29, 2026

**Type:** Tutorial

## Summary

Next.js provides out-of-the-box tracing for incoming requests, fetch calls, middleware, and server-side rendering, but traces remain invisible without a configured exporter. Developers can use the @vercel/otel package inside an instrumentation file to initialize the OpenTelemetry SDK and transmit traces to any OTLP-compatible destination. While Next.js automatically creates spans for standard request lifecycles, developers can define custom active spans in the Node runtime to capture specific domain operations and contextual attributes. Exporting traces to backends like Sentry requires configuring standard OTLP endpoint and authentication environment variables. Choosing between direct OTLP export via @vercel/otel and the dedicated Sentry SDK depends on requirements, as direct export lacks browser tracing, error monitoring, and Edge custom spans.

## Context

Next.js automatically captures traces across requests, server-side rendering, middleware, and fetch calls, but these traces are not visible unless an exporter is configured. Diagnosing slow pages without execution traces forces developers to guess bottlenecks from symptoms and reproduction attempts.

## Approach / What changed

Configure the OpenTelemetry SDK using @vercel/otel in the project root instrumentation.ts file to export traces to an OTLP-compatible backend like Sentry. Set the standard OTEL\_EXPORTER\_OTLP\_TRACES\_ENDPOINT and OTEL\_EXPORTER\_OTLP\_TRACES\_HEADERS environment variables, and optionally enrich traces with custom spans in the Node runtime using @opentelemetry/api.

## Takeaways

- @vercel/otel configures the OpenTelemetry SDK across Node and Edge runtimes, automatically loaded through Next.js startup via the register function in instrumentation.ts.
- Custom spans created via @opentelemetry/api allow developers to track domain logic and attach attributes, but @vercel/otel only supports custom spans in the Node runtime, not the Edge runtime.
- Direct OTLP exporting via @vercel/otel avoids SDK overhead but omits browser tracing, error monitoring, session replay, and source-mapped stack traces provided by @sentry/nextjs.

**Tags:** [Developer Experience](https://yomu.fyi/topic/developer-experience), [Monitoring](https://yomu.fyi/topic/monitoring), [Observability](https://yomu.fyi/topic/observability), [Performance](https://yomu.fyi/topic/performance)

[Read original post](https://blog.sentry.io/nextjs-export-traces-opentelemetry)
