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:- Go to your Vercel Dashboard
- Select your project
- Navigate to Settings → Integrations
- Search for and install the Kubiks integration
- 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:4. Configure Instrumentation
Create aninstrumentation.ts
(or .js
) file in your project root:
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 yournext.config.js
:
next.config.js
Environment Variables
Add these environment variables to your Vercel project:Variable | Description | Required |
---|---|---|
OTEL_EXPORTER_OTLP_ENDPOINT | OpenTelemetry endpoint URL | Auto-configured |
OTEL_SERVICE_NAME | Your application name | Recommended |
KUBIKS_API_KEY | Your Kubiks API key | Yes |
Add your
KUBIKS_API_KEY
in Settings → Environment Variables. Never commit API keys to source control.Instrument Your Dependencies
Enhance your observability by adding our OpenTelemetry SDKs for popular frameworks and services:Drizzle ORM
Trace all database queries and transactions
Better Auth
Monitor authentication flows and sessions
Resend
Track email delivery and operations
Upstash QStash
Monitor message queue operations
Autumn Billing
Trace billing and payment flows
View All Integrations
Explore all available SDKs
Complete Example
Here’s a complete Next.js App Router setup with Vercel OpenTelemetry:instrumentation.ts
lib/db.ts
app/api/users/route.ts
Verify Your Setup
After deploying your changes:- Deploy to Vercel:
vercel deploy
- Make some requests to your application
- Visit your Kubiks Dashboard
- View traces and logs in real-time
You should see traces appearing within seconds of requests being made to your application.
Troubleshooting
No traces appearing
No traces appearing
Check these common issues:
- Verify
instrumentationHook: true
is set innext.config.js
- Ensure
KUBIKS_API_KEY
environment variable is set in Vercel - Confirm
instrumentation.ts
is in the project root - Check deployment logs for any OpenTelemetry errors
- Verify you’ve redeployed after making configuration changes
Logs not streaming
Logs not streaming
Verify log drain configuration:
- Check Settings → Log Drains in Vercel dashboard
- Ensure the endpoint is correctly configured
- Test the log drain connection in Vercel settings
- Check your Kubiks dashboard for any ingestion errors
Missing dependency traces
Missing dependency traces
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…