Skip to content

Commit

Permalink
feat: use NoopTracerProvider if Sdk is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
GCalmels committed Jun 11, 2024
1 parent f2b25a0 commit d2eb277
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Tracing/Tracing.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
use OpenTelemetry\API\Trace\SpanKind;
use OpenTelemetry\API\Trace\TracerProviderInterface;
use OpenTelemetry\Context\Context;
use OpenTelemetry\SDK\Sdk;
use OpenTelemetry\SDK\Trace\NoopTracerProvider;

final class Tracing
{
Expand Down Expand Up @@ -46,6 +48,9 @@ public static function setProvider(TracerProviderInterface $tracerProvider): voi

private static function getProvider(): TracerProviderInterface
{
if (Sdk::isDisabled()) {
return new NoopTracerProvider();
}
if (!self::$tracerProvider) {
throw new \RuntimeException('No trace provider was set.');
}
Expand Down

0 comments on commit d2eb277

Please sign in to comment.