Skip to content
Download

Send OpenTelemetry from Laravel to your Mac

PHP instruments Laravel with an extension and a Composer package. No code changes.

  • Loggerhead is open.
  • You know the effective port. Open Collectors → Loggerhead receiver → Connection and copy the HTTP port. The first workspace uses 4318. See Ports and the effective port.

Auto-instrumentation needs the opentelemetry PHP extension.

Terminal window
pecl install opentelemetry

Add extension=opentelemetry.so to your php.ini, then check it with php -m | grep opentelemetry.

Terminal window
composer require \
open-telemetry/sdk \
open-telemetry/exporter-otlp \
open-telemetry/opentelemetry-auto-laravel
.env
OTEL_PHP_AUTOLOAD_ENABLED=true
OTEL_SERVICE_NAME=my-laravel-app
OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4318
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf

OTEL_PHP_AUTOLOAD_ENABLED is the switch. Without it the packages load and do nothing.

Start the app with php artisan serve and open one route.

Signal State
Traces Every request, with the route, the queries, and the queued jobs.
Metrics Only what you record yourself.
Logs Add OTEL_LOGS_EXPORTER=otlp and the Monolog handler of the Laravel package.
Terminal window
OTEL_RESOURCE_ATTRIBUTES=deployment.environment.name=staging

See Workspaces and environments.

  1. Open Traces in Loggerhead and click a request to open its waterfall.
  2. Connect your coding agent once, and it reads the same data. See Claude Code.