OpenTelemetry PHP

ConfigurationTest extends TestCase
in package
uses TestState

Attributes
#[CoversClass]
\OpenTelemetry\SDK\Common\Configuration\Configuration::class

Table of Contents

Constants

ALLOW_EMPTY  = [\OpenTelemetry\SDK\Common\Configuration\VariableTypes::LIST, \OpenTelemetry\SDK\Common\Configuration\VariableTypes::MAP, \OpenTelemetry\SDK\Common\Configuration\VariableTypes::MIXED]
DEFAULT_VALUES  = ['log level' => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_LOG_LEVEL, \OpenTelemetry\SDK\Common\Configuration\Defaults::OTEL_LOG_LEVEL], 'attribute count limit' => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_ATTRIBUTE_COUNT_LIMIT, \OpenTelemetry\SDK\Common\Configuration\Defaults::OTEL_ATTRIBUTE_COUNT_LIMIT], 'trace exporter' => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_PHP_TRACES_PROCESSOR, \OpenTelemetry\SDK\Common\Configuration\Defaults::OTEL_PHP_TRACES_PROCESSOR]]
KNOWN_VALUES  = ['log level' => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_LOG_LEVEL, \OpenTelemetry\SDK\Common\Configuration\KnownValues::OTEL_LOG_LEVEL], 'trace sampler' => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_TRACES_SAMPLER, \OpenTelemetry\SDK\Common\Configuration\KnownValues::OTEL_TRACES_SAMPLER], 'trace processor' => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_PHP_TRACES_PROCESSOR, \OpenTelemetry\SDK\Common\Configuration\KnownValues::OTEL_PHP_TRACES_PROCESSOR]]
LIBRARY_DEFAULTS  = [\OpenTelemetry\SDK\Common\Configuration\VariableTypes::STRING => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_EXPORTER_OTLP_ENDPOINT, 'http://localhost:4318'], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::BOOL => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_EXPORTER_OTLP_INSECURE, false], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::INTEGER => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_BSP_MAX_QUEUE_SIZE, 2048], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::ENUM => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_LOG_LEVEL, 'info'], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::LIST => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_PROPAGATORS, ['tracecontext', 'baggage']]]
METHOD_NAMES  = [\OpenTelemetry\SDK\Common\Configuration\VariableTypes::STRING => ['getString'], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::BOOL => ['getBoolean'], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::INTEGER => ['getInt'], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::FLOAT => ['getFloat'], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::RATIO => ['getRatio'], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::ENUM => ['getEnum'], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::LIST => ['getList'], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::MAP => ['getMap'], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::MIXED => ['getMixed']]
NO_DEFAULTS  = [\OpenTelemetry\SDK\Common\Configuration\VariableTypes::STRING => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_SERVICE_NAME], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::ENUM => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_EXPORTER_OTLP_COMPRESSION], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::MAP => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_EXPORTER_OTLP_HEADERS], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::MIXED => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_TRACES_SAMPLER_ARG]]
TYPES  = [\OpenTelemetry\SDK\Common\Configuration\VariableTypes::STRING => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_SERVICE_NAME], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::BOOL => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_EXPORTER_OTLP_INSECURE], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::INTEGER => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_BSP_MAX_QUEUE_SIZE], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::ENUM => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_LOG_LEVEL], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::LIST => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_PROPAGATORS], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::MAP => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_RESOURCE_ATTRIBUTES], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::MIXED => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_TRACES_SAMPLER_ARG]]
USER_ENV_VALUES  = [\OpenTelemetry\SDK\Common\Configuration\VariableTypes::STRING => ['foo', 'foo'], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::BOOL => ['true', true], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::INTEGER => ['42', 42], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::ENUM => ['val1', 'val1'], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::LIST => ['val1,val2', ['val1', 'val2']], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::MAP => ['var1=val1,var2=val2', ['var1' => 'val1', 'var2' => 'val2']], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::MIXED => ['foo', 'foo']]
USER_VALUES  = [\OpenTelemetry\SDK\Common\Configuration\VariableTypes::STRING => ['foo', 'foo'], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::BOOL => ['true', true], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::INTEGER => ['42', 42], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::ENUM => ['val1', 'val1'], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::LIST => [['val1', 'val2'], ['val1', 'val2']], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::MAP => [['var1' => 'val1', 'var2' => 'val2'], ['var1' => 'val1', 'var2' => 'val2']], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::MIXED => ['foo', 'foo']]

Properties

$environmentVariables  : array<string|int, mixed>

Methods

booleanProvider()  : array<string|int, mixed>
defaultValueProvider()  : array<string|int, mixed>
emptyProvider()  : array<string|int, mixed>
environment_variables_integer_uses_default_if_env_var_not_defined()  : void
invalidTypeProvider()  : Generator
knownValuesProvider()  : array<string|int, mixed>
libraryDefaultValueProvider()  : Generator
noDefaultProvider()  : Generator
nonEmptyMethodNameProvider()  : Generator
nonStringProvider()  : array<string|int, mixed>
test_bool_get()  : void
test_bool_uses_default_when_empty_value()  : void
test_default_ratio_for_non_existent_variable()  : void
test_enum_get()  : void
test_get_default_value()  : void
test_get_default_value_with_empty_var()  : void
test_get_known_values()  : void
test_get_non_string_value()  : void
test_get_type()  : void
test_has_variable_from_environment()  : void
test_int_uses_default_when_empty_value()  : void
test_integer_failure()  : void
test_integer_get()  : void
test_invalid_type_throws_exception()  : void
test_list_get()  : void
test_map_get()  : void
test_no_value_throws_exception()  : void
test_null_result_throws_exception()  : void
test_ratio_get()  : void
test_retrieve_value_library_default()  : void
test_return_library_default_value()  : void
test_return_user_default_value()  : void
test_return_user_env_vars()  : void
test_string_get()  : void
test_string_uses_default_when_empty_value()  : void
The SDK MUST interpret an empty value of an environment variable the same way as when the variable is unset
typeProvider()  : array<string|int, mixed>
userEnvValueProvider()  : Generator
userValueProvider()  : Generator
restoreEnvironmentVariables()  : void
setEnvironmentVariable()  : void
tearDownSharedState()  : void

Constants

ALLOW_EMPTY

private mixed ALLOW_EMPTY = [\OpenTelemetry\SDK\Common\Configuration\VariableTypes::LIST, \OpenTelemetry\SDK\Common\Configuration\VariableTypes::MAP, \OpenTelemetry\SDK\Common\Configuration\VariableTypes::MIXED]

DEFAULT_VALUES

private mixed DEFAULT_VALUES = ['log level' => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_LOG_LEVEL, \OpenTelemetry\SDK\Common\Configuration\Defaults::OTEL_LOG_LEVEL], 'attribute count limit' => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_ATTRIBUTE_COUNT_LIMIT, \OpenTelemetry\SDK\Common\Configuration\Defaults::OTEL_ATTRIBUTE_COUNT_LIMIT], 'trace exporter' => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_PHP_TRACES_PROCESSOR, \OpenTelemetry\SDK\Common\Configuration\Defaults::OTEL_PHP_TRACES_PROCESSOR]]

KNOWN_VALUES

private mixed KNOWN_VALUES = ['log level' => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_LOG_LEVEL, \OpenTelemetry\SDK\Common\Configuration\KnownValues::OTEL_LOG_LEVEL], 'trace sampler' => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_TRACES_SAMPLER, \OpenTelemetry\SDK\Common\Configuration\KnownValues::OTEL_TRACES_SAMPLER], 'trace processor' => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_PHP_TRACES_PROCESSOR, \OpenTelemetry\SDK\Common\Configuration\KnownValues::OTEL_PHP_TRACES_PROCESSOR]]

LIBRARY_DEFAULTS

private mixed LIBRARY_DEFAULTS = [\OpenTelemetry\SDK\Common\Configuration\VariableTypes::STRING => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_EXPORTER_OTLP_ENDPOINT, 'http://localhost:4318'], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::BOOL => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_EXPORTER_OTLP_INSECURE, false], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::INTEGER => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_BSP_MAX_QUEUE_SIZE, 2048], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::ENUM => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_LOG_LEVEL, 'info'], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::LIST => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_PROPAGATORS, ['tracecontext', 'baggage']]]

METHOD_NAMES

private mixed METHOD_NAMES = [\OpenTelemetry\SDK\Common\Configuration\VariableTypes::STRING => ['getString'], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::BOOL => ['getBoolean'], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::INTEGER => ['getInt'], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::FLOAT => ['getFloat'], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::RATIO => ['getRatio'], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::ENUM => ['getEnum'], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::LIST => ['getList'], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::MAP => ['getMap'], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::MIXED => ['getMixed']]

NO_DEFAULTS

private mixed NO_DEFAULTS = [\OpenTelemetry\SDK\Common\Configuration\VariableTypes::STRING => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_SERVICE_NAME], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::ENUM => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_EXPORTER_OTLP_COMPRESSION], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::MAP => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_EXPORTER_OTLP_HEADERS], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::MIXED => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_TRACES_SAMPLER_ARG]]

TYPES

private mixed TYPES = [\OpenTelemetry\SDK\Common\Configuration\VariableTypes::STRING => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_SERVICE_NAME], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::BOOL => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_EXPORTER_OTLP_INSECURE], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::INTEGER => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_BSP_MAX_QUEUE_SIZE], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::ENUM => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_LOG_LEVEL], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::LIST => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_PROPAGATORS], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::MAP => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_RESOURCE_ATTRIBUTES], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::MIXED => [\OpenTelemetry\SDK\Common\Configuration\Variables::OTEL_TRACES_SAMPLER_ARG]]

USER_ENV_VALUES

private mixed USER_ENV_VALUES = [\OpenTelemetry\SDK\Common\Configuration\VariableTypes::STRING => ['foo', 'foo'], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::BOOL => ['true', true], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::INTEGER => ['42', 42], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::ENUM => ['val1', 'val1'], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::LIST => ['val1,val2', ['val1', 'val2']], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::MAP => ['var1=val1,var2=val2', ['var1' => 'val1', 'var2' => 'val2']], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::MIXED => ['foo', 'foo']]

USER_VALUES

private mixed USER_VALUES = [\OpenTelemetry\SDK\Common\Configuration\VariableTypes::STRING => ['foo', 'foo'], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::BOOL => ['true', true], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::INTEGER => ['42', 42], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::ENUM => ['val1', 'val1'], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::LIST => [['val1', 'val2'], ['val1', 'val2']], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::MAP => [['var1' => 'val1', 'var2' => 'val2'], ['var1' => 'val1', 'var2' => 'val2']], \OpenTelemetry\SDK\Common\Configuration\VariableTypes::MIXED => ['foo', 'foo']]

Properties

$environmentVariables

private array<string|int, mixed> $environmentVariables = []

Methods

booleanProvider()

public static booleanProvider() : array<string|int, mixed>
Return values
array<string|int, mixed>

defaultValueProvider()

public static defaultValueProvider() : array<string|int, mixed>
Return values
array<string|int, mixed>

emptyProvider()

public static emptyProvider() : array<string|int, mixed>
Return values
array<string|int, mixed>

environment_variables_integer_uses_default_if_env_var_not_defined()

public environment_variables_integer_uses_default_if_env_var_not_defined() : void

invalidTypeProvider()

public static invalidTypeProvider() : Generator
Return values
Generator

knownValuesProvider()

public static knownValuesProvider() : array<string|int, mixed>
Return values
array<string|int, mixed>

libraryDefaultValueProvider()

public static libraryDefaultValueProvider() : Generator
Return values
Generator

noDefaultProvider()

public static noDefaultProvider() : Generator
Return values
Generator

nonEmptyMethodNameProvider()

public static nonEmptyMethodNameProvider() : Generator
Return values
Generator

nonStringProvider()

public static nonStringProvider() : array<string|int, mixed>
Return values
array<string|int, mixed>

test_bool_get()

public test_bool_get(string $input, bool $default, bool $expected) : void
Parameters
$input : string
$default : bool
$expected : bool
Attributes
#[DataProvider]
'booleanProvider'

test_bool_uses_default_when_empty_value()

public test_bool_uses_default_when_empty_value(string|null $input) : void
Parameters
$input : string|null
Attributes
#[DataProvider]
'emptyProvider'

test_default_ratio_for_non_existent_variable()

public test_default_ratio_for_non_existent_variable() : void

test_get_default_value()

public test_get_default_value(string $varName, mixed $varValue) : void
Parameters
$varName : string
$varValue : mixed
Attributes
#[DataProvider]
'defaultValueProvider'

test_get_default_value_with_empty_var()

public test_get_default_value_with_empty_var(string $varName, mixed $varValue) : void
Parameters
$varName : string
$varValue : mixed
Attributes
#[DataProvider]
'defaultValueProvider'

test_get_known_values()

public test_get_known_values(string $varName, array<string|int, mixed> $varValue) : void
Parameters
$varName : string
$varValue : array<string|int, mixed>
Attributes
#[DataProvider]
'knownValuesProvider'

test_get_non_string_value()

public test_get_non_string_value(string $method, mixed $value) : void
Parameters
$method : string
$value : mixed
Attributes
#[DataProvider]
'nonStringProvider'

test_get_type()

public test_get_type(string $varName, string $type) : void
Parameters
$varName : string
$type : string
Attributes
#[DataProvider]
'typeProvider'

test_has_variable_from_environment()

public test_has_variable_from_environment() : void

test_int_uses_default_when_empty_value()

public test_int_uses_default_when_empty_value(string|null $input) : void
Parameters
$input : string|null
Attributes
#[DataProvider]
'emptyProvider'

test_invalid_type_throws_exception()

public test_invalid_type_throws_exception(string $methodName, string $variable) : void
Parameters
$methodName : string
$variable : string
Attributes
#[DataProvider]
'invalidTypeProvider'

test_no_value_throws_exception()

public test_no_value_throws_exception(string $methodName) : void
Parameters
$methodName : string
Attributes
#[DataProvider]
'nonEmptyMethodNameProvider'

test_null_result_throws_exception()

public test_null_result_throws_exception(string $methodName, string $variable) : void
Parameters
$methodName : string
$variable : string
Attributes
#[DataProvider]
'noDefaultProvider'

test_retrieve_value_library_default()

public test_retrieve_value_library_default() : void

test_return_library_default_value()

public test_return_library_default_value(string $methodName, string $variable, mixed $result) : void
Parameters
$methodName : string
$variable : string
$result : mixed
Attributes
#[DataProvider]
'libraryDefaultValueProvider'

test_return_user_default_value()

public test_return_user_default_value(string $methodName, string $variable, mixed $defaultValue, mixed $result) : void
Parameters
$methodName : string
$variable : string
$defaultValue : mixed
$result : mixed
Attributes
#[DataProvider]
'userValueProvider'

test_return_user_env_vars()

public test_return_user_env_vars(string $methodName, string $variable, string $value, mixed $result) : void
Parameters
$methodName : string
$variable : string
$value : string
$result : mixed
Attributes
#[DataProvider]
'userEnvValueProvider'

test_string_uses_default_when_empty_value()

The SDK MUST interpret an empty value of an environment variable the same way as when the variable is unset

public test_string_uses_default_when_empty_value(string|null $input) : void
Parameters
$input : string|null
Attributes
#[DataProvider]
'emptyProvider'

typeProvider()

public static typeProvider() : array<string|int, mixed>
Return values
array<string|int, mixed>

userEnvValueProvider()

public static userEnvValueProvider() : Generator
Return values
Generator

userValueProvider()

public static userValueProvider() : Generator
Return values
Generator

restoreEnvironmentVariables()

protected restoreEnvironmentVariables() : void
Attributes
#[After]

setEnvironmentVariable()

protected setEnvironmentVariable(string $variable, mixed $value) : void
Parameters
$variable : string
$value : mixed

tearDownSharedState()

protected tearDownSharedState() : void
Attributes
#[After]

        
On this page

Search results