Skip to content

Commit

Permalink
retrieve OTEL_PHP_FIBERS_ENABLED from configuration library
Browse files Browse the repository at this point in the history
  • Loading branch information
brettmc committed Mar 5, 2024
1 parent 684d650 commit 176a67d
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/Config/ValueTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions src/Config/Variables.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
11 changes: 3 additions & 8 deletions src/Context/ZendObserverFiber.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Context switches on execution context switch.
--SKIPIF--
<?php if (PHP_VERSION_ID < 80100 || !extension_loaded('ffi')) die('skip requires PHP8.1 and FFI'); ?>
--ENV--
OTEL_PHP_FIBERS_ENABLED=1
OTEL_PHP_FIBERS_ENABLED=true
--FILE--
<?php
use OpenTelemetry\Context\Context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Fiber handler has to be loaded before fibers are used.
--SKIPIF--
<?php if (PHP_VERSION_ID < 80100 || !extension_loaded('ffi')) die('skip requires PHP8.1 and FFI'); ?>
--ENV--
OTEL_PHP_FIBERS_ENABLED=1
OTEL_PHP_FIBERS_ENABLED=true
--FILE--
<?php
use OpenTelemetry\Context\Context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Context usage in fiber without fiber support triggers warning.
--SKIPIF--
<?php if (!class_exists(Fiber::class)) die('skip requires fibers'); ?>
--ENV--
OTEL_PHP_FIBERS_ENABLED=0
OTEL_PHP_FIBERS_ENABLED=false
--FILE--
<?php
use OpenTelemetry\Context\Context;
Expand Down

0 comments on commit 176a67d

Please sign in to comment.