Skip to content

eerzho/opentelemetry-auto-class-symfony

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

opentelemetry-auto-class-symfony

Version Downloads PHP License

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.

Installation

composer require eerzho/opentelemetry-auto-class-symfony

Register the bundle:

// config/bundles.php
return [
    // ...
    Eerzho\Instrumentation\Class\Symfony\AutoClassBundle::class => ['all' => true],
];

Requirements:

Usage

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.

How it works

  1. During container compilation, scans all service definitions for the #[Trace] attribute
  2. Builds a method map and stores it as a container parameter
  3. On kernel boot, registers ext-opentelemetry hooks for matched methods

Only classes registered as services are discovered — a #[Trace] class that is never wired into the container is not instrumented.

Disabling instrumentation

OTEL_PHP_DISABLED_INSTRUMENTATIONS=class

About

One tag, full visibility — every method call in your Symfony app shows up in your traces, zero config.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages