diff --git a/src/SDK/Sdk.php b/src/SDK/Sdk.php index 3b63eb93a..e172f90d2 100644 --- a/src/SDK/Sdk.php +++ b/src/SDK/Sdk.php @@ -43,6 +43,11 @@ public static function isInstrumentationDisabled(string $name): bool return in_array($name, Configuration::getList(Variables::OTEL_PHP_DISABLED_INSTRUMENTATIONS)); } + public static function isAutoloadEnabled(): bool + { + return Configuration::getBoolean(Variables::OTEL_PHP_AUTOLOAD_ENABLED); + } + public static function builder(): SdkBuilder { return new SdkBuilder(); diff --git a/tests/Unit/SDK/SdkTest.php b/tests/Unit/SDK/SdkTest.php index a862efe41..bf20bf498 100644 --- a/tests/Unit/SDK/SdkTest.php +++ b/tests/Unit/SDK/SdkTest.php @@ -68,6 +68,24 @@ public static function instrumentationDisabledProvider(): array ]; } + /** + * @dataProvider autoloadEnabledProvider + */ + public function test_is_autoload_enabled(string $value, bool $expected): void + { + $this->setEnvironmentVariable(Variables::OTEL_PHP_AUTOLOAD_ENABLED, $value); + + $this->assertSame($expected, Sdk::isAutoloadEnabled()); + } + + public static function autoloadEnabledProvider(): array + { + return [ + ['true', true], + ['false', false], + ]; + } + public function test_builder(): void { $this->assertInstanceOf(SdkBuilder::class, Sdk::builder());