One tag, full visibility — every method call in your Symfony app shows up in your traces, zero config.
The Symfony integration for opentelemetry-auto-class — your classes are discovered and registered automatically.
This is a read-only sub-split. Please open issues and pull requests in the monorepo.
composer require eerzho/opentelemetry-auto-class-symfonyRegister the bundle:
// config/bundles.php
return [
// ...
Eerzho\Instrumentation\Class\Symfony\AutoClassBundle::class => ['all' => true],
];Requirements:
- ext-opentelemetry
- PHP 8.2+
- Symfony 6+
Add #[Trace] to any class registered as a service:
namespace App\Service;
use Eerzho\Instrumentation\Class\Attribute\Trace;
use Eerzho\Instrumentation\Class\Attribute\TraceArguments;
use Eerzho\Instrumentation\Class\Attribute\TraceProperties;
#[Trace(exclude: ['healthCheck'])] // trace public methods, but hide "healthCheck"
class OrderService
{
// span "App\Service\OrderService::pay"
#[TraceArguments(exclude: ['card'])] // hide "card" from the span
public function pay(int $orderId, string $card, Address $address): void {}
public function healthCheck(): bool {}
}
#[TraceProperties(exclude: ['zip'])] // expand public props, but hide "zip"
class Address
{
public function __construct(public string $city, public string $zip) {}
}All three attributes and their options are fully documented in the core.
- During container compilation, scans all service definitions for the
#[Trace]attribute - Builds a method map and stores it as a container parameter
- On kernel boot, registers
ext-opentelemetryhooks for matched methods
Only classes registered as services are discovered — a
#[Trace]class that is never wired into the container is not instrumented.
OTEL_PHP_DISABLED_INSTRUMENTATIONS=class