Monitor a Next.js app with Lampwick

Add instrumentation.ts with @vercel/otel and point it at Lampwick. Next.js App Router requests, queries and server errors show up, over OpenTelemetry.

Updated View as Markdown

Next.js has OpenTelemetry built in. Add an instrumentation.ts that calls @vercel/otel, set 4 environment variables, and every server request and server-side error goes to Lampwick. We tested it with Next.js 16 (App Router, next start).

What you get

  • Requests, grouped by route, such as GET /orders/[id].
  • Queries, with the pg instrumentation below.
  • Issues from server-side errors, tied to the request they happened in.

Set it up

Terminal
npm install @vercel/otel @opentelemetry/api @opentelemetry/api-logs @opentelemetry/instrumentation @opentelemetry/sdk-logs

Create instrumentation.ts in the project root (or in src/):

TypeScript
import { registerOTel } from '@vercel/otel';

export function register() {
  registerOTel({ serviceName: 'my-app' });
}

Set these in .env.local, or on Vercel under Settings → Environment Variables:

.env
OTEL_EXPORTER_OTLP_ENDPOINT=https://app.lampwick.dev
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
OTEL_EXPORTER_OTLP_HEADERS=x-lampwick-token=YOUR_PROJECT_TOKEN
OTEL_METRICS_EXPORTER=none

YOUR_PROJECT_TOKEN is the project's ingest token, from the Connect your app card on its Settings page. For database queries, add PgInstrumentation (version 0.76.0); the Next.js docs show how.

What it doesn't do

  • Stack traces point into .next/server/chunks/. Next.js bundles server code and Lampwick doesn't apply source maps. The message and the request are exact.
  • Logs aren't sent. console.log isn't captured and @vercel/otel exports no logs.
  • Browser errors need the browser snippet as well.
  • Edge runtime: we tested the Node.js runtime only.

Let your agent do it

Add OpenTelemetry to this Next.js app so it reports to Lampwick: follow https://lampwick.dev/docs/nextjs.md exactly (instrumentation.ts with @vercel/otel, the environment variables, PgInstrumentation only if the app uses pg). Read the ingest token from the environment, never commit it.

Next step

The Next.js docs have the app we tested, what showed up and the troubleshooting table. How spans map to Lampwick: OpenTelemetry.