Skip to main content

Overview

Get complete observability for your Vercel applications by enabling OpenTelemetry tracing and log drains. Monitor your application performance, track API calls, and debug issues with distributed tracing.

Quick Setup

1. Connect Your Project

Add the Kubiks integration to your Vercel project:
  1. Go to your Vercel Dashboard
  2. Select your project
  3. Navigate to SettingsIntegrations
  4. Search for and install the Kubiks integration
  5. Authorize access to your project
The integration will automatically configure log and trace drains for your project.

2. Enable Log & Trace Drains

Configure Vercel to send logs and traces to your observability platform:
  • Via Kubiks Integration
  • Manual Configuration
Log and trace drains are automatically configured when you install the Kubiks integration.

3. Install OpenTelemetry SDK

Add the Vercel OpenTelemetry SDK to your application:
npm install @vercel/otel @opentelemetry/api

4. Configure Instrumentation

Create an instrumentation.ts (or .js) file in your project root:
import { registerOTel } from '@vercel/otel';

export function register() {
  registerOTel({
    serviceName: 'your-app-name',
    // Automatically sends to configured trace endpoint
  });
}
Next.js 13.2+ automatically loads instrumentation.ts when present. For older versions, manually import it in your application entry point.

5. Enable in Next.js Config

Add instrumentation support to your next.config.js:
next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
  experimental: {
    instrumentationHook: true,
  },
};

module.exports = nextConfig;

Environment Variables

Add these environment variables to your Vercel project:
VariableDescriptionRequired
OTEL_EXPORTER_OTLP_ENDPOINTOpenTelemetry endpoint URLAuto-configured
OTEL_SERVICE_NAMEYour application nameRecommended
KUBIKS_API_KEYYour Kubiks API keyYes
Add your KUBIKS_API_KEY in SettingsEnvironment Variables. Never commit API keys to source control.

Instrument Your Dependencies

Enhance your observability by adding our OpenTelemetry SDKs for popular frameworks and services:

Complete Example

Here’s a complete Next.js App Router setup with Vercel OpenTelemetry:
instrumentation.ts
import { registerOTel } from '@vercel/otel';

export function register() {
  registerOTel({
    serviceName: process.env.OTEL_SERVICE_NAME || 'my-nextjs-app',
  });
}
lib/db.ts
import { drizzle } from 'drizzle-orm/postgres-js';
import { instrumentDrizzleClient } from '@kubiks/otel-drizzle';

export const db = drizzle(process.env.DATABASE_URL!);

// Add Drizzle instrumentation
instrumentDrizzleClient(db, {
  dbSystem: 'postgresql',
  captureQueryText: true,
});
app/api/users/route.ts
import { NextResponse } from 'next/server';
import { db } from '@/lib/db';
import { users } from '@/db/schema';

export async function GET() {
  // Automatically traced with parent Vercel request span
  const allUsers = await db.select().from(users);
  return NextResponse.json(allUsers);
}

Verify Your Setup

After deploying your changes:
  1. Deploy to Vercel: vercel deploy
  2. Make some requests to your application
  3. Visit your Kubiks Dashboard
  4. View traces and logs in real-time
You should see traces appearing within seconds of requests being made to your application.

Troubleshooting

Check these common issues:
  1. Verify instrumentationHook: true is set in next.config.js
  2. Ensure KUBIKS_API_KEY environment variable is set in Vercel
  3. Confirm instrumentation.ts is in the project root
  4. Check deployment logs for any OpenTelemetry errors
  5. Verify you’ve redeployed after making configuration changes
Verify log drain configuration:
  1. Check SettingsLog Drains in Vercel dashboard
  2. Ensure the endpoint is correctly configured
  3. Test the log drain connection in Vercel settings
  4. Check your Kubiks dashboard for any ingestion errors
Instrument your dependencies:OpenTelemetry only traces HTTP requests by default. Add our specialized SDKs to trace:
  • Database queries (Drizzle)
  • Auth operations (Better Auth)
  • Email sending (Resend)
  • Queue operations (Upstash)
  • And more…
See the OpenTelemetry Integrations for all available SDKs.

Resources

I