Skip to main content
This guide will help you instrument your Laravel application(s) with OpenTelemetry and send traces to Checkly.

Step 1: Install the OpenTelemetry extension

Check if the opentelemetry extension is properly installed and enabled:
You should see something similar to:
If you are not getting a similar output, check your php.ini file and make sure a line is added similar to this:
Now install the automatic Laravel instrumentation.
Terminal

Step 2: Install the OpenTelemetry SDK

Terminal
Now install the automatic Laravel instrumentation.

Step 3: Initialize the instrumentation

This example shows all the code you will need to add to your index.php. Notice the ChecklySampler class. 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.
index.php

Step 3: 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. Checkly OTEL API keys Now, export your API key in your shell by setting the OTEL_EXPORTER_OTLP_HEADERS environment variable.
Terminal
Next, export the endpoint for the region you want to use and give your service a name.
Terminal
Then, explicitly set the protocol to use for the OTLP exporter.
Terminal
We are using the standard OpenTelemetry environment variables here to configure the OTLP exporter. Finally, start your app:
Terminal
🎉 You are done. Any interactions with your app that are triggered by a Checkly synthetic monitoring check will now generate traces, which are sent back to Checkly and displayed in the Checkly UI.