From e0b6bbd57e9a3ff19e488d73fc08b0c742795df8 Mon Sep 17 00:00:00 2001 From: Jonathan Lee Date: Tue, 9 Jan 2024 10:54:55 -0800 Subject: [PATCH] tag app with controller.service_arguments, update `use` statements --- SampleApp/config/services.yaml | 4 ++++ .../src/Controller/AwsSdkInstrumentationController.php | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/SampleApp/config/services.yaml b/SampleApp/config/services.yaml index 2d6a76f..77aee4e 100644 --- a/SampleApp/config/services.yaml +++ b/SampleApp/config/services.yaml @@ -20,5 +20,9 @@ services: - '../src/Entity/' - '../src/Kernel.php' + App\Controller\: + resource: '../src/Controller' + tags: ['controller.service_arguments'] + # add more service definitions when explicit configuration is needed # please note that last definitions always *replace* previous ones diff --git a/SampleApp/src/Controller/AwsSdkInstrumentationController.php b/SampleApp/src/Controller/AwsSdkInstrumentationController.php index 4dc4bfd..e7d44a6 100644 --- a/SampleApp/src/Controller/AwsSdkInstrumentationController.php +++ b/SampleApp/src/Controller/AwsSdkInstrumentationController.php @@ -5,7 +5,8 @@ use Aws\S3\S3Client; use OpenTelemetry\API\Trace\SpanKind; -use OpenTelemetry\API\Common\Signal\Signals; +use OpenTelemetry\API\Signals; +use OpenTelemetry\API\LoggerHolder; use OpenTelemetry\Contrib\Otlp\OtlpUtil; use OpenTelemetry\Contrib\Otlp\SpanExporter; @@ -24,7 +25,12 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Annotation\Route; -\OpenTelemetry\API\Common\Log\LoggerHolder::set(new \Monolog\Logger('grpc', [new \Monolog\Handler\StreamHandler('php://stderr')])); +use Monolog\Handler\StreamHandler; +use Monolog\Logger; + +LoggerHolder::set( + new Logger('grpc', [new StreamHandler('php://stderr')]) +); class AwsSdkInstrumentationController {