Traces from Vercel and Next.js: from the app or with a Trace Drain
The OpenTelemetry Node SDK in instrumentation.ts, Trace Drains on Pro and Enterprise, and why Log Drains need a Collector.
On this page
Two ways to get traces from an app on Vercel into Belvador: let your app export them (any plan), or let Vercel forward its own traces with a Trace Drain (Pro and Enterprise). Logs need the first way — Vercel's Log Drains do not speak OTLP.
Not tested yet: this setup follows the vendor's documentation; Belvador has not run it end to end.
From your app (Next.js)#
Next.js loads instrumentation.ts at start-up. Export with the standard OpenTelemetry Node SDK in the Node.js runtime only — it does not run in the Edge runtime:
// instrumentation.tsexport async function register() { if (process.env.NEXT_RUNTIME === "nodejs") { await import("./instrumentation.node"); }}// instrumentation.node.tsimport { getNodeAutoInstrumentations } from "@opentelemetry/auto-instrumentations-node";import { NodeSDK } from "@opentelemetry/sdk-node";new NodeSDK({ instrumentations: [getNodeAutoInstrumentations()] }).start();Install @opentelemetry/sdk-node and @opentelemetry/auto-instrumentations-node, and set the standard variables in Project Settings → Environment Variables — the key as a sensitive variable, never a NEXT_PUBLIC_ one. The SDK reads the endpoint, header, service name and environment from them, and sends logs from Pino, Bunyan or Winston as on Node.js.
@vercel/otel (registerOTel) also works if you prefer it; give it an explicit OTLP exporter so it does not pick a Vercel-configured one.
Serverless functions freeze when the response is sent, so a batch can wait until the next request or be lost. Belvador has not measured how much on Vercel.
With a Trace Drain (Pro, Enterprise)#
Vercel forwards the traces it records for your deployments — no code. In Team Settings → Drains → Add Drain:
| Field | Value |
|---|---|
| Data | Traces |
| Projects | The projects to forward |
| Endpoint | https://ingest.belvador.dev/otlp/<project-id>/v1/traces |
| Format | Protobuf |
| Custom header | Authorization: Bearer <ingest key> |
Use an ingest key with Traces. Vercel also adds its own x-vercel-signature header; Belvador authenticates with the bearer key and ignores it. Sampling rules run top to bottom and drop requests no rule matches; with no rule, every trace is forwarded. Resource attributes include vercel.projectId and vercel.deploymentId.
Logs from Vercel's Log Drains#
Log Drains send Vercel's JSON or NDJSON, not OTLP, so Belvador's logs endpoint cannot read them directly. Send logs from the app as above, or put a Collector in between with a receiver that parses Vercel's format.
Status#
Both ways follow Vercel's and OpenTelemetry's documentation; Belvador has not run them on Vercel yet, so they are marked untested. After setup, run the connection check and look for your service under Services seen.
Spotted something wrong or missing? Tell us: hello@belvador.dev