Prompt
API observability / monitoring
Latest observation
For API observability and monitoring in a Next.js app (logs, metrics, tracing, latency/error visibility, and overall request “delivery” performance), here’s the practical path in 2026.
Recommended Starting Point
Next.js has first-class support for OpenTelemetry via the instrumentation.ts file. This is the official, framework-supported way to get server-side tracing for API routes, route handlers, fetches, and more. It works on Vercel and self-hosted setups and stays vendor-neutral.
Quick Setup with @vercel/otel (recommended)
Bash
pnpm add @vercel/otel @opentelemetry/sdk-logs @opentelemetry/api-logs @opentelemetry/instrumentation
Create instrumentation.ts (or src/instrumentation.ts) in the project root:
TypeScript
import { registerOTel } from '@vercel/otel'
export function register() {
registerOTel({ serviceName: 'your-nextjs-app' })
}
This automatically instruments:
- Incoming requests (including API routes / Route Handlers)
- Outgoing fetch calls
- Many Next.js internals (rendering, etc.)
You can later add custom spans with the OpenTelemetry API.
If You’re on Vercel
Use the built-in Vercel Observability:
- Free tier gives function invocations, durations, error rates, external API calls, CDN requests, etc.
- Observability Plus (usage-based, currently ~$1.20 per million events, no base fee in recent updates) unlocks longer retention (30 days), path-level latency (p75 etc.), better querying, and more detailed breakdowns.
Combine it with @vercel/otel for richer traces that show up in the Vercel dashboard (and can be drained to other tools).
Strong Tool Combinations
| Need | Recommended Tool(s) | Why it fits Next.js well |
|---|---|---|
| Errors + performance + session replay | Sentry | Excellent Next.js SDK, source maps, full-stack traces (browser → API → DB), easy instrumentation.ts setup |
| Vendor-neutral tracing | OpenTelemetry → SigNoz, Grafana Tempo, OpenObserve, Jaeger, Uptrace | Standards-based; swap backends later |
| Full platform (enterprise) | Datadog / New Relic | Everything (APM, logs, RUM, synthetics) but heavier and more expensive |
| External uptime / “is the API reachable?” | Better Stack, UptimeRobot, Checkly | Catches outages, DNS, SSL, region issues that internal instrumentation misses |
| Lightweight / agentless | Sentry or pure OTel | Avoids heavy agents that hurt cold starts on serverless |
Most teams start with Sentry + Vercel Observability (or pure OTel if they already have a backend). Sentry is frequently cited as the highest value-to-effort choice for Next.js.
What to Actually Monitor (API “Delivery Visibility”)
Focus on these per route / per handler:
- Latency: p50 / p95 / p99 (warm vs cold starts separately if on serverless)
- Error rate: 4xx vs 5xx breakdown
- Throughput: requests per minute
- External dependencies: latency & error rate of the APIs/DBs your routes call
- Cold starts (Vercel/Lambda): frequency and added latency
- Structured logs with route, method, status, request ID / trace ID, user/tenant ID (never log secrets)
Extra Tips
- Prefer structured logging (Pino is popular and fast on Node).
- Use sampling in production (e.g. 10% traces) to control cost.
- For external uptime, also set up synthetic checks against critical endpoints — pure in-process monitoring won’t catch network/DNS/CDN failures.
- Next.js automatically creates useful spans such as executing api route (app) [next.route], fetch spans, etc. once OTel is registered.
Would you like a complete ready-to-copy setup for:
- Sentry + Next.js,
- Pure OpenTelemetry + a specific backend (e.g. SigNoz / Grafana), or
- Vercel-only + custom metrics?
Also tell me whether you’re deploying to Vercel, self-hosting, or another platform (Railway, Fly, AWS, etc.) and roughly how many API requests you expect — that changes the cost/tooling recommendations.
Brands
Citations
- https://nextjs.org/docs/app/guides/open-telemetry
- https://vercel.com/docs/observability
- https://nurbak.com/en/blog/best-nextjs-monitoring-tools-2026/
- https://blog.sentry.io/nextjs-export-traces-opentelemetry/
- https://apistatuscheck.com/blog/build-api-status-dashboard
- https://www.npmjs.com/package/next-rsc-debug
- https://makerkit.dev/docs/next-supabase-turbo/monitoring/custom-monitoring-provider
- https://johnkavanagh.co.uk/articles/production-observability-for-nextjs/
- https://technewsdaily.com/news/implementing-opentelemetry-in-nextjs-15/
- https://www.npmjs.com/package/@datadog/browser-rum-nextjs?ref=pkgstats.com
- https://nurbak.com/en/blog/serverless-monitoring/
- https://nurbak.com/en/blog/api-monitoring-no-agents-nextjs/