Skip to content
5 min read
Table of Contents
Choose a framework to optimize documentation to:

Vercel's OpenTelemetry collector is available in Beta on Pro and Enterprise plans

Vercel has an OpenTelemetry (OTEL) collector that allows you to send OTEL traces from your Serverless Functions to application performance monitoring (APM) vendors such as New Relic.

Traces are a way to collect data about the performance and behavior of your application and help identify the cause of performance issues, errors, and other problems. Learn more about traces in the OpenTelemetry docs.

To start using OpenTelemetry on Vercel, follow the steps below. This guide gives examples using Next.js and other frameworks where you can use Serverless Functions.

  • You must be using an OTEL Integration:
    • New Relic: Available in Beta to teams on Pro and Enterprise plans by following the steps below
    • DataDog: Available in Private Beta to teams on the Enterprise plan. To get access contact your CSM and follow the steps below
  • You must be using it in a Serverless Function

Select an integration from the Observability category in the Marketplace (such as DataDog or New Relic).

Datadog integration support for OTEL is only available to teams on the Enterprise plan. You must contact your CSM to get access.

Click the Add Integration button to begin the installation and follow each step to add the correct Scope.

If you already have installed an OTEL integration, you can skip this step.

To use OTEL, you must enable Traces for the Integration. You can do this either during initial setup, or if you already have the integration installed, select Manage next to the Integration in the Integrations tab and then select Configure.

For JavaScript and Typescript users on Vercel, you can use the @vercel/otel package to call the correct OpenTelemetry SDK for you.

Install the OpenTelemetry JavaScript SDK and @vercel/otel:

pnpm
yarn
npm
pnpm i @opentelemetry/api @vercel/otel

Create an instrumentation.ts file in the root of your project and add the following code to initialize and configure OTEL using @vercel/otel.

Next.js (/app)
Next.js (/pages)
instrumentation.ts
import { registerOTel } from '@vercel/otel';
 
export function register() {
  registerOTel('your-project-name');
}
// NOTE: You can replace `your-project-name` with the actual name of your project

Next.js 13.4+ supports auto-instrumentation which means you no longer have to create a span for each request. To use this feature, you must explicitly opt-in by adding experimental.instrumentationHook = true to your next.config.js.

For more information, please refer to the Next.js docs for auto-instrumentation.

If you have an existing project, you must trigger a redeployment to use traces.

You can either deploy your project through the dashboard or through the CLI.

Last updated on February 27, 2023