From 2d95cc5d8654b5359a24a20a10bc141db8fb307a Mon Sep 17 00:00:00 2001 From: Tobias Bachert Date: Fri, 8 Jul 2022 18:45:09 +0200 Subject: [PATCH] Add SDK `TracerProviderInterface` to expose `::shutdown()` and `::forceFlush()` --- src/SDK/Trace/TracerProvider.php | 4 ++-- src/SDK/Trace/TracerProviderFactory.php | 3 +-- src/SDK/Trace/TracerProviderInterface.php | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 src/SDK/Trace/TracerProviderInterface.php diff --git a/src/SDK/Trace/TracerProvider.php b/src/SDK/Trace/TracerProvider.php index 84a184a1e..61623bb78 100644 --- a/src/SDK/Trace/TracerProvider.php +++ b/src/SDK/Trace/TracerProvider.php @@ -18,7 +18,7 @@ use function spl_object_id; use WeakReference; -final class TracerProvider implements API\TracerProviderInterface +final class TracerProvider implements TracerProviderInterface { /** @var array>|null */ private static ?array $tracerProviders = null; @@ -58,7 +58,7 @@ public function __construct( self::registerShutdownFunction($this); } - public function forceFlush(): ?bool + public function forceFlush(): bool { return $this->tracerSharedState->getSpanProcessor()->forceFlush(); } diff --git a/src/SDK/Trace/TracerProviderFactory.php b/src/SDK/Trace/TracerProviderFactory.php index f27410eaa..e2f75d5a7 100644 --- a/src/SDK/Trace/TracerProviderFactory.php +++ b/src/SDK/Trace/TracerProviderFactory.php @@ -4,7 +4,6 @@ namespace OpenTelemetry\SDK\Trace; -use OpenTelemetry\API\Trace as API; use OpenTelemetry\SDK\Behavior\LogsMessagesTrait; final class TracerProviderFactory @@ -26,7 +25,7 @@ public function __construct( $this->spanProcessorFactory = $spanProcessorFactory ?: new SpanProcessorFactory(); } - public function create(): API\TracerProviderInterface + public function create(): TracerProviderInterface { try { $exporter = $this->exporterFactory->fromEnvironment(); diff --git a/src/SDK/Trace/TracerProviderInterface.php b/src/SDK/Trace/TracerProviderInterface.php new file mode 100644 index 000000000..7531795ed --- /dev/null +++ b/src/SDK/Trace/TracerProviderInterface.php @@ -0,0 +1,14 @@ +