Skip to main content

PHP OpenTelemetry traces locally

Set OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:8000 and OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf for your PHP app, with the OpenTelemetry PHP SDK and the OTLP exporter installed. Your traces then show up in Buggregator as a waterfall of spans, with the service name on each span. You need no Jaeger, no Collector and no cloud account.

Steps

1. Start Buggregator

Run the container. Port 8000 is the web UI and also takes OTLP over HTTP.

bash
docker run --pull always \
  -p 127.0.0.1:8000:8000 \
  -p 127.0.0.1:1025:1025 \
  -p 127.0.0.1:9912:9912 \
  -p 127.0.0.1:9913:9913 \
  ghcr.io/buggregator/server:latest

2. Install the extension and the SDK

Zero-code instrumentation needs the opentelemetry PHP extension. Build it and enable it in php.ini:

bash
pecl install opentelemetry
ini
[opentelemetry]
extension=opentelemetry.so

Then add the SDK, the OTLP exporter, an HTTP client for it, and the instrumentation package for your framework. This example uses Laravel's, open-telemetry/opentelemetry-auto-laravel; the OpenTelemetry registry lists packages for others.

bash
composer require \
  open-telemetry/sdk \
  open-telemetry/exporter-otlp \
  php-http/guzzle7-adapter \
  open-telemetry/opentelemetry-auto-laravel

3. Set the standard OTel variables

Set them in the environment PHP runs in. Buggregator accepts OTLP over HTTP, as protobuf or JSON. It takes traces and logs, not metrics, so turn the metrics exporter off.

dotenv
OTEL_PHP_AUTOLOAD_ENABLED=true
OTEL_SERVICE_NAME=checkout
OTEL_TRACES_EXPORTER=otlp
OTEL_METRICS_EXPORTER=none
OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:8000
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf

Give the base URL only: the SDK adds /v1/traces itself. In Docker Compose, replace 127.0.0.1 with the Buggregator service name, for example buggregator.

4. Open the Traces tab

Load a few pages, then open the Sentry page and pick Traces. Each trace carries an OTel label and the services it went through. Open one to see its spans as a waterfall, with a Service column that shows checkout.

Why it works

OTLP is the protocol OpenTelemetry uses to send data. Buggregator takes it on its main port at the standard paths /v1/traces and /v1/logs, so the SDK sends to it like to any OTLP backend. The traces land on the Sentry page next to errors from Sentry SDKs. OTEL_SERVICE_NAME becomes the service in the UI.

Checked on with Buggregator v2.13.0

Setup in 60 seconds

No registration. No account. Start it and point your app at it.

1

Start Buggregator

One file, installed with one command. The web UI opens on port 8000. Prefer containers? Use the Docker tab.

$ curl -fsSL https://raw.githubusercontent.com/buggregator/server/master/scripts/install.sh | sh
$ HTTP_ADDR=127.0.0.1:8000 \
  SMTP_ADDR=127.0.0.1:1025 \
  VAR_DUMPER_ADDR=127.0.0.1:9912 \
  MONOLOG_ADDR=127.0.0.1:9913 \
  PROXY_ADDR=127.0.0.1:8080 \
  ~/.local/bin/buggregator

The script picks the file for your CPU: Intel/AMD or ARM.

One file for Linux, macOS and Windows, about 40 MB. Nothing else to install.

This run line keeps it on this computer. Without the *_ADDR settings it listens on all network interfaces

Rather not run a script? Download the file yourself

Runs on Windows, macOS and Linux, on Intel/AMD and ARM.

Prefer not to do it yourself? Your AI agent can set Buggregator up for you