Mapleが利用可能になりました — 無料トライアルを開始する
Next.js

Next.js observability with OpenTelemetry

Add distributed tracing to your Next.js application in minutes. Capture server components, API routes, and middleware spans automatically with Vercel's built-in instrumentation hook.

Quick start

Up and running in minutes

1

Install dependencies

bash
npm install @vercel/otel @opentelemetry/sdk-logs @opentelemetry/exporter-logs-otlp-http
2

Configure instrumentation

typescript
// instrumentation.ts (project root)
import { registerOTel } from "@vercel/otel";
import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http";
import { SimpleLogRecordProcessor } from "@opentelemetry/sdk-logs";

export function register() {
  registerOTel({
    serviceName: "my-next-app",
    attributes: { environment: "production" },
    traceExporter: { url: "https://ingest.maple.dev/v1/traces" },
    logRecordProcessor: new SimpleLogRecordProcessor(
      new OTLPLogExporter({
        url: "https://ingest.maple.dev/v1/logs",
        headers: { Authorization: "Bearer your-api-key" },
      })
    ),
  });
}
What you get

Automatic instrumentation for Next.js

HTTP routes

Automatic spans for every page and route handler request with method, status, and duration.

API routes

Full tracing of API route handlers including request/response metadata.

Server Components

Spans for React Server Component rendering and data fetching.

Middleware

Traces for Next.js middleware execution including redirects and rewrites.

Database queries

Automatic instrumentation of Prisma, Drizzle, and other database clients.

External API calls

Outgoing HTTP requests traced with fetch instrumentation and context propagation.

Live trace preview

See your Next.js traces

Trace: Next.js App
GET /api/users
145ms
middleware/auth
12ms
pg.query SELECT users
34ms
fetch https://api.stripe.com
89ms
Explore more

Other integrations

明確な観測を始めませんか?

5分以内でトレース、ログ、メトリクスの送信を開始。

maple.dev — オブザーバビリティ、シンプルに