OpenTelemetry for Next.js
Next.js has OpenTelemetry built in: it creates spans for each request, render and fetch once you register a tracer in instrumentation.ts. @vercel/otel does that registration and works on Vercel, in Node.js and on the edge runtime.
What you get
- Every request as a trace, with its database calls and outgoing HTTP calls, in Traces.
- Requests matched to your business flows by service and route on our side, so you see "checkout is failing at place order" rather than a list of endpoints.
- Exceptions grouped into Issues, slow and N+1 database queries on each database's page, and deploys found from
service.version. - Alerts, incidents and the on-call agent, which reads these traces when something breaks.
Set it up
1. Install
npm install @vercel/otel @opentelemetry/api @opentelemetry/api-logs @opentelemetry/sdk-logs @opentelemetry/instrumentation
2. Register it
// instrumentation.ts, in the project root (or in src/)
import { registerOTel } from "@vercel/otel";
export function register() {
registerOTel({ serviceName: "web" });
}
Next.js 15 and later load this file on their own. Next.js 13.4 and 14 also need experimental: { instrumentationHook: true } in next.config.js.
3. Point it at Flowhawk
First create an ingest key: in the app, open Settings > API keys and pick Services. In the examples below, KEY stands for that key. Keep it out of your repository, like any other secret.
Set these in your deployment's environment (in Vercel, Project Settings > Environment Variables). @vercel/otel exports over OTLP when they are set:
OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.flowhawk.dev
OTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer%20KEY
OTEL_RESOURCE_ATTRIBUTES=deployment.environment=production
Check it arrived
Open Setup in the app. It lists each service that sent data in the last 15 minutes. If yours isn't there, Help and troubleshooting says why telemetry can be refused (a wrong key, an empty balance) and how to see it.
The browser side
For errors, page loads, web vitals and session replay from the pages themselves, add @flowhawk/browser with a public Web pages key. Its sessions link to the backend traces they started (Sending data).
Common questions
And my Vercel logs?
Add a Vercel log drain. Logs that carry a trace id open their trace.
I use the Vercel AI SDK. Do I see model calls?
Yes. Turn on its telemetry and Flowhawk's AI page shows each call's model, tokens, cost and latency by flow (LLM observability).