Laravel OpenTelemetry traces on your machine
Install the OpenTelemetry PHP extension and the Laravel auto-instrumentation package, then set OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:8000. Each Laravel request then shows up in Buggregator as a trace: the request, its database queries and its HTTP client calls as spans on one timeline. No Jaeger, no Grafana, no account.
Steps
1. Start Buggregator
It takes OTLP over HTTP on the same port as its UI, 8000.
docker run --pull always \
-p 127.0.0.1:8000:8000 \
ghcr.io/buggregator/server:latest2. Install the OpenTelemetry extension
Auto-instrumentation needs the opentelemetry PHP extension. Install it with PECL, or with install-php-extensions opentelemetry in a Docker image, then enable it.
pecl install opentelemetry[opentelemetry]
extension=opentelemetry.soCheck it with php -m | grep opentelemetry.
3. Add the packages
The SDK, the OTLP exporter and the Laravel instrumentation.
composer require open-telemetry/sdk open-telemetry/exporter-otlp open-telemetry/opentelemetry-auto-laravel4. Point the SDK at Buggregator
Put these lines in php.ini (or another ini file PHP reads), or set them as environment variables of the PHP process. Laravel's .env is not enough: the SDK starts when Composer's autoloader runs, before Laravel reads .env.
OTEL_PHP_AUTOLOAD_ENABLED="true"
OTEL_SERVICE_NAME="laravel"
OTEL_TRACES_EXPORTER="otlp"
OTEL_LOGS_EXPORTER="otlp"
OTEL_METRICS_EXPORTER="none"
OTEL_EXPORTER_OTLP_PROTOCOL="http/protobuf"
OTEL_EXPORTER_OTLP_ENDPOINT="http://127.0.0.1:8000"In Docker Compose, use the service name: http://buggregator:8000. Buggregator takes http/protobuf or http/json, not grpc. It does not take metrics, so metrics export is off here.
5. Open Sentry, then Traces
Load a page of your app. In Buggregator, open the Sentry page and pick Traces. The row is labelled OTel and shows the service name. Open it to see the spans as a waterfall, with a Service column. Laravel logs sent through OpenTelemetry show up under Logs and link to their trace.
Why it works
The Laravel package hooks into the HTTP kernel, the database and the HTTP client, and creates spans without code changes. The OTLP exporter sends them to /v1/traces on the endpoint you set. Buggregator accepts OTLP on port 8000 and shows OTel traces on the Sentry page, next to traces from Sentry SDKs. OTEL_SERVICE_NAME is what you see as the service.
Docs: docs.buggregator.dev/config/opentelemetry.html#otel-sdk
Requires Buggregator v2.12.0+
Related tips
- Sentry
See a Laravel request's Sentry trace as a waterfall
Turn on Sentry tracing in Laravel and send it to Buggregator. Every span of a request shows on a timeline, and errors link to their trace.
- OpenTelemetry
PHP OpenTelemetry traces locally
Send OpenTelemetry PHP SDK traces to Buggregator with the standard OTEL_ variables. Each request shows as a waterfall of spans on your machine.
- OpenTelemetry
Add Buggregator to your OTel Collector as one more exporter
Add an otlphttp exporter to your Collector config. Traces and logs from every service show up in Buggregator, and the apps stay as they are.
- Profiler
Find the slow function in a Laravel page
Install XHProf and one Laravel package, point it at Buggregator, and read the flamechart and top functions of every request.
Checked on with Buggregator v2.13.0