Before you start
You need:- A Next.js application using at least Next.js 14.
Step 1. Install the @vercel/otel
package
For Next.js, Vercel has created a wrapper that should get you going very quickly. We’re just adding some extra packages
so we can filter out the Checkly Traces.
Terminal
Make sure to install v1.9.1 or later of the
@vercel/otel
package as it contains a critical bug fix for Vercel’s Edge runtime.Step 2. [Only in Next.js 14]: Initialize the instrumentation
Set theinstrumentationHook
flag to true
in your Next.js configuration file. This will enable the OpenTelemetry instrumentation.
next.config.js
Step 3. Set up the instrumentation
Create aninstrumentation.ts
file in the root of your project, or, place it in the src
directory if you are using one.
And add the following code:
instrumentation.ts
@vercel/otel
package, which is configured by using the auto
value.
This package is compatible with Vercel’s Edge runtime, in contrast to the @opentelemetry/exporter-trace-otlp-http
package, which is not.
If you are not using Vercel or don’t use Vercel’s Edge runtime, you can also use the @opentelemetry/exporter-trace-otlp-http
and just follow the regular Node.js instrumentation guide.
This is however not required, the above configuration should work just fine on Node.js and Edge runtimes.
Also notice the sampler
configuration. This is a custom, head-based sampler that will only sample spans that are generated by Checkly by
inspecting the trace state. This way you only pay for the egress traffic generated by Checkly and not for any other traffic.
Step 5 (Local development). Start your app with the instrumentation
Toggle on Import Traces and grab your OTel API key in the OTel API keys section of the Traces page in the Checkly app and take a note of the endpoint for the region you want to use.
OTEL_EXPORTER_OTLP_HEADERS
environment variable.
Terminal
Terminal
Terminal
Variable | Description |
---|---|
OTEL_EXPORTER_OTLP_HEADERS | The Authorization HTTP header containing your Checkly OTel API key. |
OTEL_EXPORTER_OTLP_ENDPOINT | The Checkly OTel API endpoint for the region you want to use. |
OTEL_EXPORTER_OTLP_PROTOCOL | The protocol to use for the OTLP exporter. |
OTEL_SERVICE_NAME | The name of your service to identify it among the spans in the web UI. |
Step 6 (Vercel deployment). Set up environment variables.
When using Vercel to host your Next.js app,5.1. First, add the environment variables to your Vercel project settings:
OTEL_EXPORTER_OTLP_HEADERS
, with the OTel API key you get in Traces settings, using theauthorization=ot_
.OTEL_EXPORTER_OTLP_ENDPOINT
, use: https://otel.eu-west-1.checklyhq.com, withoutv1/traces
.OTEL_SERVICE_NAME
, your applications’ name.OTEL_LOG_LEVEL
, set the log level todebug
as to see the span sampling.

5.2. Run a check and confirm it works!
Schedule a check, you should see the Vercel logs reportingSampling decision for Checkly span: #
and soon the spans will show up in your check results page as well.