OpenTelemetry on Vercel
When deploying applications or functions on Vercel, you can use Vercel's built-in OpenTelemetry collector to forward telemetry data to AppSignal through our collector.
Make sure to install the AppSignal collector before proceeding with these instructions.
See also the Vercel OpenTelemetry installation guide.
Install the OpenTelemetry packages
Use npm to add the Vercel Metrics, the OpenTelemetry SDK and the OTLP exporter to your application's dependencies:
npm install @opentelemetry/api \ @opentelemetry/sdk-metrics \ @opentelemetry/exporter-trace-otlp-proto \ @opentelemetry/exporter-metrics-otlp-proto \ @vercel/otel
Configure OpenTelemetry in your application
If you're using Next.js. Add the instrumentation.ts
file to your application. It must be placed in the root directory of the project (or inside src folder if using one).
If you're using other frameworks or Vercel functions, make sure that this code is loaded early in the execution process to properly capture OpenTelemetry data.
import { registerOTel } from "@vercel/otel"; import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-proto"; import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-proto"; import { PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics"; const collectorHost = "https://your-appsignal-collector-host.com"; export function register() { registerOTel({ serviceName: "My service", traceExporter: new OTLPTraceExporter({ url: `${collectorHost}/v1/traces`, }), metricReader: new PeriodicExportingMetricReader({ exportIntervalMillis: 1000, exporter: new OTLPMetricExporter({ url: `${collectorHost}/v1/metrics`, }), }), attributes: { "appsignal.config.name": "My app", "appsignal.config.environment": "production", "appsignal.config.revision": "1", "appsignal.config.language_integration": "nodejs", "appsignal.config.push_api_key": "0000-0000-0000-0000", "host.name": "vercel", }, }); }
Test the app!
Now that all the components are connected, start your app with the required command line arguments and test if you see data arrive in AppSignal. Check the "Errors > Issue list" and "Performance > Traces" page specifically.
If after following our installation instructions you still don't see data in AppSignal, let us know and we'll help you finalize your OpenTelemetry installation!