OpenTelemetry for Symfony

Trace every request, database query and outgoing call of a Symfony app with OpenTelemetry's auto-instrumentation, and send it to Flowhawk.

OpenTelemetry for PHP instruments Symfony through a PHP extension and Composer packages. Your controllers don't change: requests, Doctrine and PDO queries, and HttpClient calls become spans.

What you get

  • Every request as a trace, with its database calls and outgoing HTTP calls, in Traces.
  • Requests matched to your business flows by service and route on our side, so you see "checkout is failing at place order" rather than a list of endpoints.
  • Exceptions grouped into Issues, slow and N+1 database queries on each database's page, and deploys found from service.version.
  • Alerts, incidents and the on-call agent, which reads these traces when something breaks.

Set it up

1. Install the extension and the packages

pecl install opentelemetry          # the extension auto-instrumentation needs
composer require open-telemetry/sdk open-telemetry/exporter-otlp \
  open-telemetry/opentelemetry-auto-symfony open-telemetry/opentelemetry-auto-pdo

Enable the extension in your php.ini (extension=opentelemetry) for both PHP-FPM and the CLI, so Messenger workers and console commands are traced too. Check with php --ri opentelemetry.

2. Point it at Flowhawk

First create an ingest key: in the app, open Settings > API keys and pick Services. In the examples below, KEY stands for that key. Keep it out of your repository, like any other secret.

Set these in the environment of PHP-FPM and your workers (Symfony's .env is read too late):

OTEL_PHP_AUTOLOAD_ENABLED=true
OTEL_SERVICE_NAME=orders
OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.flowhawk.dev
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
OTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer%20KEY
OTEL_RESOURCE_ATTRIBUTES=deployment.environment=production,service.version=1.4.2

The space in the header is written %20. Set service.version to your release, so a deploy shows as a change next to the flows it made better or worse.

3. Deploy and send a request

Each request becomes a trace named after its route, with its queries and outgoing calls as spans inside it.

Check it arrived

Open Setup in the app. It lists each service that sent data in the last 15 minutes. If yours isn't there, Help and troubleshooting says why telemetry can be refused (a wrong key, an empty balance) and how to see it.

Common questions

Is there a Flowhawk SDK for PHP?

It isn't on Packagist yet. Plain OpenTelemetry as above works today: Flowhawk matches your requests to flows by service and route. Switching to the SDK later adds exact flow tags across services and sampling per flow, and nothing else changes.

What about Laravel or Slim?

See the Laravel guide, or use open-telemetry/opentelemetry-auto-slim for Slim (PHP guide).