opentelemetry-auto-class-laravel maintained by eerzho
Description
Trace what your Laravel methods received, returned, and threw — without writing a single span.
Author
Last update
2026/07/20 21:44
(dev-main)
License
Downloads
1
Tags
package - php - trace - laravel - instrumentation - tracing - laravel-package - opentelemetry - otel - auto-instrumentation
opentelemetry-auto-class-laravel
One tag, full visibility — every method call in your Laravel app shows up in your traces, zero config.
The Laravel 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-laravel
Requirements:
- ext-opentelemetry
- PHP 8.2+
- Laravel 10+
Configuration
Scanned namespaces default to App\. To customize, publish the config:
php artisan vendor:publish --tag=trace-config
// config/trace.php
return [
'namespaces' => [
'App\\Services\\',
'App\\Jobs\\',
'Domain\\',
],
];
Usage
Add #[Trace] to any class in a scanned namespace:
namespace App\Services;
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\Services\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
On boot the service provider:
- Reads namespaces from
config/trace.php - Discovers classes in those namespaces via Composer's
ClassLoader::getClassMap() - Scans them for the
#[Trace]attribute - Registers
ext-opentelemetryhooks for matched methods
Only classes present in the Composer class map are discovered — run
composer dump-autoload -oin production so nothing is missed.
Disabling instrumentation
OTEL_PHP_DISABLED_INSTRUMENTATIONS=class