-
Notifications
You must be signed in to change notification settings - Fork 6
/
Sdk.php
75 lines (61 loc) · 2.15 KB
/
Sdk.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
declare(strict_types=1);
namespace OpenTelemetry\SDK;
use OpenTelemetry\API\Logs\EventLoggerProviderInterface;
use OpenTelemetry\API\Metrics\MeterProviderInterface;
use OpenTelemetry\API\Trace\TracerProviderInterface;
use OpenTelemetry\Context\Propagation\TextMapPropagatorInterface;
use OpenTelemetry\SDK\Common\Configuration\Configuration;
use OpenTelemetry\SDK\Common\Configuration\Variables;
use OpenTelemetry\SDK\Logs\LoggerProviderInterface;
class Sdk
{
private const OTEL_PHP_DISABLED_INSTRUMENTATIONS_ALL = 'all';
public function __construct(
private readonly TracerProviderInterface $tracerProvider,
private readonly MeterProviderInterface $meterProvider,
private readonly LoggerProviderInterface $loggerProvider,
private readonly EventLoggerProviderInterface $eventLoggerProvider,
private readonly TextMapPropagatorInterface $propagator,
) {
}
public static function isDisabled(): bool
{
return Configuration::getBoolean(Variables::OTEL_SDK_DISABLED);
}
/**
* Tests whether an auto-instrumentation package has been disabled by config
*/
public static function isInstrumentationDisabled(string $name): bool
{
$disabledInstrumentations = Configuration::getList(Variables::OTEL_PHP_DISABLED_INSTRUMENTATIONS);
return [self::OTEL_PHP_DISABLED_INSTRUMENTATIONS_ALL] === $disabledInstrumentations || in_array($name, $disabledInstrumentations);
}
public static function builder(): SdkBuilder
{
return new SdkBuilder();
}
public function getTracerProvider(): TracerProviderInterface
{
return $this->tracerProvider;
}
public function getMeterProvider(): MeterProviderInterface
{
return $this->meterProvider;
}
public function getLoggerProvider(): LoggerProviderInterface
{
return $this->loggerProvider;
}
/**
* @deprecated
*/
public function getEventLoggerProvider(): EventLoggerProviderInterface
{
return $this->eventLoggerProvider;
}
public function getPropagator(): TextMapPropagatorInterface
{
return $this->propagator;
}
}