diff --git a/src/Config/ValueTypes.php b/src/Config/ValueTypes.php index 5e7cefca9..77a815b03 100644 --- a/src/Config/ValueTypes.php +++ b/src/Config/ValueTypes.php @@ -132,4 +132,5 @@ interface ValueTypes public const OTEL_PHP_DISABLED_INSTRUMENTATIONS = VariableTypes::LIST; public const OTEL_PHP_DEBUG_SCOPES_DISABLED = VariableTypes::BOOL; public const OTEL_PHP_EXCLUDED_URLS = VariableTypes::LIST; + public const OTEL_PHP_FIBERS_ENABLED = VariableTypes::BOOL; } diff --git a/src/Config/Variables.php b/src/Config/Variables.php index 41129e455..ee8a820e5 100644 --- a/src/Config/Variables.php +++ b/src/Config/Variables.php @@ -141,4 +141,5 @@ interface Variables public const OTEL_PHP_DEBUG_SCOPES_DISABLED = 'OTEL_PHP_DEBUG_SCOPES_DISABLED'; public const OTEL_PHP_DISABLED_INSTRUMENTATIONS = 'OTEL_PHP_DISABLED_INSTRUMENTATIONS'; public const OTEL_PHP_EXCLUDED_URLS = 'OTEL_PHP_EXCLUDED_URLS'; + public const OTEL_PHP_FIBERS_ENABLED = 'OTEL_PHP_FIBERS_ENABLED'; } diff --git a/src/Context/ZendObserverFiber.php b/src/Context/ZendObserverFiber.php index 4d3d0c5ef..e9ac847a7 100644 --- a/src/Context/ZendObserverFiber.php +++ b/src/Context/ZendObserverFiber.php @@ -11,9 +11,8 @@ use function extension_loaded; use FFI; -use const FILTER_VALIDATE_BOOLEAN; -use function filter_var; -use function is_string; +use OpenTelemetry\Config\Configuration; +use OpenTelemetry\Config\Variables; use const PHP_VERSION_ID; use const PHP_ZTS; use function sprintf; @@ -26,11 +25,7 @@ final class ZendObserverFiber { public static function isEnabled(): bool { - $enabled = $_SERVER['OTEL_PHP_FIBERS_ENABLED'] ?? false; - - return is_string($enabled) - ? filter_var($enabled, FILTER_VALIDATE_BOOLEAN) - : (bool) $enabled; + return Configuration::getBoolean(Variables::OTEL_PHP_FIBERS_ENABLED, false); } public static function init(): bool diff --git a/tests/Integration/Context/Fiber/test_context_switching_ffi_observer.phpt b/tests/Integration/Context/Fiber/test_context_switching_ffi_observer.phpt index f6ce0eb81..90acc2f86 100644 --- a/tests/Integration/Context/Fiber/test_context_switching_ffi_observer.phpt +++ b/tests/Integration/Context/Fiber/test_context_switching_ffi_observer.phpt @@ -3,7 +3,7 @@ Context switches on execution context switch. --SKIPIF-- --ENV-- -OTEL_PHP_FIBERS_ENABLED=1 +OTEL_PHP_FIBERS_ENABLED=true --FILE-- --ENV-- -OTEL_PHP_FIBERS_ENABLED=1 +OTEL_PHP_FIBERS_ENABLED=true --FILE-- --ENV-- -OTEL_PHP_FIBERS_ENABLED=0 +OTEL_PHP_FIBERS_ENABLED=false --FILE--