open-telemetry / opentelemetry-php

The OpenTelemetry PHP Library
https://opentelemetry.io/docs/instrumentation/php/
Apache License 2.0
756 stars 187 forks source link

Laravel. Add ability to disable logger watcher from open-telemetry/opentelemetry-auto-laravel. #1424

Open GDXbsv opened 3 weeks ago

GDXbsv commented 3 weeks ago

open-telemetry/opentelemetry-auto-laravel 1.0.0

Steps to reproduce Install open-telemetry/opentelemetry-auto-laravel 1.0.0 And activate open-telemetry/opentelemetry-logger-monolog

final class LaravelLoggerCreating
{
    public function __invoke(array $config)
    {
       $log = new Logger('test');
       $otelHandler = new Handler(
            Globals::loggerProvider(),
            LogLevel::INFO
        );
        $log->pushHandler($otelHandler);

        return $log;
     }
}
    'channels' => [
        'app' => [
            'driver' => 'custom',
            'via' => new LaravelLoggerCreating(),
            'app_name' => 'Test',
            'channel' => 'test',
            'processors' => [],
            'level' => Logger::INFO,
        ],

What is the expected behavior? I would expect an ability to use my own custom logger as it is described in docs.

What is the actual behavior? I see logs from open-telemetry/opentelemetry-auto-laravel 1.0.0 and from my logger (they are doubled actually)

ChrisLightfootWild commented 3 weeks ago

There's no mechanism yet to allow disabling parts of the instrumentation, but this is something to consider on the back of #1422 - and that's coincidentally very close to what I'd like as part of "the future".