Skip to content

Commit 0530e5d

Browse files
authored
feat: Allow OTEL_PHP_DEBUG_SCOPES_DISABLED as en environment variable (#1237)
* fix: Allow OTEL_PHP_DEBUG_SCOPES_DISABLED env var + use of null-coalescing operator * refactor: Check order & env reset * refactor: Use class constant * fix: Respect order and value if it is set * style: Lint * tests: Falsey behavior
1 parent e9d254a commit 0530e5d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Context.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
use function assert;
88
use const FILTER_VALIDATE_BOOLEAN;
99
use function filter_var;
10-
use function ini_get;
1110
use function spl_object_id;
1211

1312
/**
1413
* @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/context/README.md#context
1514
*/
1615
final class Context implements ContextInterface
1716
{
17+
private const OTEL_PHP_DEBUG_SCOPES_DISABLED = 'OTEL_PHP_DEBUG_SCOPES_DISABLED';
18+
1819
/** @var ContextStorageInterface&ExecutionContextAwareInterface */
1920
private static ContextStorageInterface $storage;
2021

@@ -91,9 +92,10 @@ public function activate(): ScopeInterface
9192

9293
private static function debugScopesDisabled(): bool
9394
{
94-
$disabled = $_SERVER['OTEL_PHP_DEBUG_SCOPES_DISABLED'] ?? ini_get('OTEL_PHP_DEBUG_SCOPES_DISABLED');
95-
96-
return filter_var($disabled, FILTER_VALIDATE_BOOLEAN);
95+
return filter_var(
96+
$_SERVER[self::OTEL_PHP_DEBUG_SCOPES_DISABLED] ?? \getenv(self::OTEL_PHP_DEBUG_SCOPES_DISABLED) ?: \ini_get(self::OTEL_PHP_DEBUG_SCOPES_DISABLED),
97+
FILTER_VALIDATE_BOOLEAN
98+
);
9799
}
98100

99101
public function withContextValue(ImplicitContextKeyedInterface $value): ContextInterface

0 commit comments

Comments
 (0)