DEV Community

Cover image for OpenTelemetry for Symfony: v2.0 is out
Jovan Stojiljkovic
Jovan Stojiljkovic

Posted on

OpenTelemetry for Symfony: v2.0 is out

We shipped v2.0 of traceway/opentelemetry-symfony today.

Two months ago, v1.0 launched with HTTP, Messenger, and HttpClient tracing. It is a pure-PHP
OpenTelemetry bundle for Symfony, with no C extension required. That post covered the why. This one covers what nine stable releases added since:

  • v1.5: DBAL 3 and 4 tracing in the same package. NamespacedPoolInterface support for cache.
  • v1.6: OTel native log export. Monolog handler with per-channel instrumentation scope, microsecond timestamp precision, exception attributes, re-entrance guard against export-path recursion.
  • v1.7: metrics foundation. MeterRegistry service plus Messenger consume-side metrics (messaging.process.duration, messaging.client.consumed.messages).
  • v1.8: full metrics rollout. Doctrine db.client.operation.duration, HTTP client http.client.request.duration (Stable semconv), Messenger dispatch metrics. Log records got OTel code.* semconv attributes from Monolog's IntrospectionProcessor. The Tracing helper joined the bundle-wide ResetInterface pattern.
  • v1.9: Mailer instrumentation (PRODUCER and CLIENT span split with ECS-aligned email.* attributes), Scheduler instrumentation (CONSUMER span per scheduled-task run, Messenger middleware auto-dedups envelopes carrying ScheduledStamp), HTTP server and Mailer transport metrics. PHPUnit 13 support across the test matrix.
  • v2.0: nested signal-grouped config plus BC layer.

Every release shipped stable, no betas. PHPStan level 10 with no baseline throughout.

v2.0 restructures the config from flat keys to a nested, signal-grouped shape aligned with the OpenTelemetry spec and the OTEL_* env-var convention:

  # v1.x: still works, emits a Symfony deprecation
  open_telemetry:
      traces_enabled: true
      messenger_enabled: true
      log_export_enabled: true

  # v2.0: nested under traces / metrics / logs
  open_telemetry:
      traces:
          enabled: true
          messenger:
              enabled: true
      logs:
          export:
              enabled: true
Enter fullscreen mode Exit fullscreen mode

Every v1.x flat key keeps working; each one emits a Symfony deprecation pointing at the new nested location, scheduled for removal in v3.0. Setting both flat and nested in the same block throws an
InvalidConfigurationException rather than silently picking one. Upgrading requires zero edits, and you get a deprecation pass to migrate on your own schedule. Full mapping in
UPGRADE-2.0.md.

One default also flipped: logs.export.unprefixed_attributes is now true by default. Monolog context and extra fields are emitted as flat OTel attributes instead of under monolog.context.* /
monolog.extra.* prefixes, matching how every other ecosystem does it (Java logback, Python LoggingHandler, .NET OpenTelemetryLogger, JS Winston). The knob has existed since v1.8.0 so users had a
release cycle to opt in. Set it back to false explicitly if your dashboards depend on the prefixed shape.

Getting started is two steps:

  composer require traceway/opentelemetry-symfony
Enter fullscreen mode Exit fullscreen mode
  OTEL_PHP_AUTOLOAD_ENABLED=true
  OTEL_SERVICE_NAME=my-symfony-app
  OTEL_TRACES_EXPORTER=otlp
  OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
  OTEL_EXPORTER_OTLP_PROTOCOL=http/json
Enter fullscreen mode Exit fullscreen mode

With Symfony Flex the bundle auto-registers. Every HTTP request, console command, outgoing call, Messenger job, DB query, cache operation, and Twig render is now traced. Point it at any OTel-compatible
backend: Traceway, Jaeger, Tempo, Datadog, Honeycomb, and the rest.

v2.1 will land Monolog handler ergonomics: a channels filter and configurable exception keys, driven by community feedback in issue
#23
. Issues and PRs welcome.

GitHub logo tracewayapp / opentelemetry-symfony-bundle

Pure-PHP OpenTelemetry instrumentation for Symfony - automatic HTTP, HttpClient, and Messenger tracing. No C extension required

Traceway Logo

OpenTelemetry Symfony Bundle

CI codecov Packagist Version Packagist Downloads PHP Version Symfony Version License Discord

Pure-PHP OpenTelemetry instrumentation for Symfony — automatic tracing for HTTP, Console, HttpClient, Messenger, Mailer, Scheduler, Doctrine DBAL, Cache, and Twig, plus Monolog log-trace correlation, OpenTelemetry log export, and opt-in metrics for Messenger, DBAL, HTTP server/client, and Mailer. No C extension required.

Works with any OpenTelemetry-compatible backend: Traceway, Jaeger, Zipkin, Datadog, Grafana Tempo, Honeycomb, and more.

  • Pure PHP — no C extension required; installs on every managed Symfony host
  • Production-ready — stable since v1.0, PHPStan level 10 with no baseline, supports Symfony 6.4 LTS through 8.x
  • Correct under load — Messenger trace context propagates across async queue boundaries, Doctrine DBAL 3 and 4 both CI-tested, re-entrance guards prevent export-path recursion in HttpClient and the log handler

Quick Start

composer require traceway/opentelemetry-symfony
Enter fullscreen mode Exit fullscreen mode
OTEL_PHP_AUTOLOAD_ENABLED=true
OTEL_SERVICE_NAME=my-symfony-app
OTEL_TRACES_EXPORTER=otlp
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
OTEL_EXPORTER_OTLP_PROTOCOL=http/json
# Optional: OTEL_RESOURCE_ATTRIBUTES=service.version=1.0
Enter fullscreen mode Exit fullscreen mode

Use http/json unless…

Top comments (0)