Skip to main content
Use this guide when your Next.js app already initializes OpenTelemetry or receives telemetry through platform drains. To send data from a native OTel exporter or Collector, see OpenTelemetry ingestion.

Use an existing OpenTelemetry provider

Use one OpenTelemetry bootstrap per process. If you already initialize @vercel/otel, dd-trace, or a custom provider, use buildInterfereOtelKit() to add Interfere to that setup instead of also calling Interfere’s register().
instrumentation.ts
The kit constructs processors, propagators, and resource attributes without registering providers globally. It returns null when INTERFERE_PUBLIC_KEY is unset.

Compose processors and propagators

Append kit.propagators after your trace-context propagator, as in propagators: ["auto", ...kit.propagators], to preserve browser-to-server correlation. Merge the kit’s resource attributes with your own. Pass the same service name to the kit and your host bootstrap so spans retain consistent service and release attribution. If you already have an onRequestError handler, call Interfere’s handler inside it as well. Keep both behaviors instead of replacing one export with the other. Only one browser SDK should inject W3C trace context for a given request URL. If another SDK also writes traceparent, scope its injection to other hosts or use its vendor-specific propagation where supported. Competing headers can break browser-to-server correlation. Skip the console bridge when your logger already emits the same records through OpenTelemetry. Avoid adding a second HTTP instrumentation for requests already traced by Next.js or your host setup. The kit does not publish releases or upload source maps. Keep the build plugin configured.

Browser-to-server traces

Keep both the build plugin and browser initialization from the Next.js guide. On dynamically rendered pages, they connect browser activity to the server request. The composed setup above also needs kit.propagators for that connection. Static pages and Edge-rendered pages start separate browser traces. Capture still works, but those pages do not have the same server-to-browser link. On Edge, buildInterfereOtelKit() returns null; the optional chaining in the example lets it load without registering a Node.js provider.

Server telemetry

Under @vercel/otel, a direct OTLP exporter flushes inside waitUntil, so each invocation stays billed until the export finishes. With a Vercel trace drain enabled for the app, the SDK switches to drain mode automatically and avoids that cost: Vercel ships spans out of process. Without a drain, the SDK exports directly and caps each export on Vercel at 2 seconds.