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 — 옵저버빌리티, 심플하게