diff options
Diffstat (limited to 'vendor/open-telemetry/sdk/Common/Configuration')
15 files changed, 1176 insertions, 0 deletions
diff --git a/vendor/open-telemetry/sdk/Common/Configuration/Configuration.php b/vendor/open-telemetry/sdk/Common/Configuration/Configuration.php new file mode 100644 index 000000000..58673fd98 --- /dev/null +++ b/vendor/open-telemetry/sdk/Common/Configuration/Configuration.php @@ -0,0 +1,182 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\SDK\Common\Configuration; + +use InvalidArgumentException; +use OpenTelemetry\API\Behavior\LogsMessagesTrait; +use OpenTelemetry\SDK\Common\Configuration\Parser\BooleanParser; +use OpenTelemetry\SDK\Common\Configuration\Parser\ListParser; +use OpenTelemetry\SDK\Common\Configuration\Parser\MapParser; +use OpenTelemetry\SDK\Common\Configuration\Parser\RatioParser; +use OpenTelemetry\SDK\Common\Configuration\Resolver\CompositeResolver; +use OpenTelemetry\SDK\Common\Util\ClassConstantAccessor; +use UnexpectedValueException; + +/** + * Configuration can come from one or more of the following sources (from highest to lowest priority): + * - values defined in php.ini + * - environment variable ($_SERVER) + * - configuration file (todo) + */ +class Configuration +{ + use LogsMessagesTrait; + + public static function has(string $name): bool + { + return CompositeResolver::instance()->hasVariable($name); + } + + public static function getInt(string $key, int $default = null): int + { + return (int) self::validateVariableValue( + CompositeResolver::instance()->resolve( + self::validateVariableType($key, VariableTypes::INTEGER), + $default + ), + FILTER_VALIDATE_INT + ); + } + + public static function getString(string $key, string $default = null): string + { + return (string) self::validateVariableValue( + CompositeResolver::instance()->resolve( + self::validateVariableType($key, VariableTypes::STRING), + $default + ) + ); + } + + public static function getBoolean(string $key, bool $default = null): bool + { + $resolved = self::validateVariableValue( + CompositeResolver::instance()->resolve( + self::validateVariableType($key, VariableTypes::BOOL), + null === $default ? $default : ($default ? 'true' : 'false') + ) + ); + + try { + return BooleanParser::parse($resolved); + } catch (InvalidArgumentException $e) { + self::logWarning(sprintf('Invalid boolean value "%s" interpreted as "false" for %s', $resolved, $key)); + + return false; + } + } + + public static function getMixed(string $key, $default = null) + { + return self::validateVariableValue( + CompositeResolver::instance()->resolve( + $key, + $default + ) + ); + } + + public static function getMap(string $key, array $default = null): array + { + return MapParser::parse( + CompositeResolver::instance()->resolve( + self::validateVariableType($key, VariableTypes::MAP), + $default + ) + ); + } + + public static function getList(string $key, array $default = null): array + { + return ListParser::parse( + CompositeResolver::instance()->resolve( + self::validateVariableType($key, VariableTypes::LIST), + $default + ) + ); + } + + public static function getEnum(string $key, string $default = null): string + { + return (string) self::validateVariableValue( + CompositeResolver::instance()->resolve( + self::validateVariableType($key, VariableTypes::ENUM), + $default + ) + ); + } + + public static function getFloat(string $key, float $default = null): float + { + return (float) self::validateVariableValue( + CompositeResolver::instance()->resolve( + self::validateVariableType($key, VariableTypes::FLOAT), + $default + ), + FILTER_VALIDATE_FLOAT + ); + } + + public static function getRatio(string $key, float $default = null): float + { + return RatioParser::parse( + self::validateVariableValue( + CompositeResolver::instance()->resolve( + self::validateVariableType($key, VariableTypes::RATIO), + $default + ) + ) + ); + } + + public static function getKnownValues(string $variableName): ?array + { + return ClassConstantAccessor::getValue(KnownValues::class, $variableName); + } + + public static function getDefault(string $variableName) + { + return ClassConstantAccessor::getValue(Defaults::class, $variableName); + } + + public static function getType(string $variableName): ?string + { + return ClassConstantAccessor::getValue(ValueTypes::class, $variableName); + } + + public static function isEmpty($value): bool + { + // don't use 'empty()', since '0' is not considered to be empty + return $value === null || $value === ''; + } + + private static function validateVariableType(string $variableName, string $type): string + { + $variableType = self::getType($variableName); + + if ($variableType !== null && $variableType !== $type && $variableType !== VariableTypes::MIXED) { + throw new UnexpectedValueException( + sprintf('Variable "%s" is not supposed to be of type "%s" but type "%s"', $variableName, $type, $variableType) + ); + } + + return $variableName; + } + + private static function validateVariableValue($value, ?int $filterType = null) + { + if ($filterType !== null && filter_var($value, $filterType) === false) { + throw new UnexpectedValueException(sprintf('Value has invalid type "%s"', gettype($value))); + } + + if ($value === null || $value === '') { + throw new UnexpectedValueException( + 'Variable must not be null or empty' + ); + } + + return $value; + } +} diff --git a/vendor/open-telemetry/sdk/Common/Configuration/Defaults.php b/vendor/open-telemetry/sdk/Common/Configuration/Defaults.php new file mode 100644 index 000000000..7228270a6 --- /dev/null +++ b/vendor/open-telemetry/sdk/Common/Configuration/Defaults.php @@ -0,0 +1,122 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\SDK\Common\Configuration; + +/** + * Default values for environment variables defined by the OpenTelemetry specification and language specific variables for the PHP SDK. + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md + */ +interface Defaults +{ + /** + * General SDK Configuration + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#general-sdk-configuration + */ + public const OTEL_LOG_LEVEL = 'info'; + public const OTEL_PROPAGATORS = 'tracecontext,baggage'; + public const OTEL_TRACES_SAMPLER = 'parentbased_always_on'; + public const OTEL_SDK_DISABLED = 'false'; + /** + * Batch Span Processor + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#batch-span-processor + */ + public const OTEL_BSP_SCHEDULE_DELAY = 5000; + public const OTEL_BSP_EXPORT_TIMEOUT = 30000; + public const OTEL_BSP_MAX_QUEUE_SIZE = 2048; + public const OTEL_BSP_MAX_EXPORT_BATCH_SIZE = 512; + /** + * Batch LogRecord Processor + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#batch-logrecord-processor + */ + public const OTEL_BLRP_SCHEDULE_DELAY = 1000; + public const OTEL_BLRP_EXPORT_TIMEOUT = 30000; + public const OTEL_BLRP_MAX_QUEUE_SIZE = 2048; + public const OTEL_BLRP_MAX_EXPORT_BATCH_SIZE = 512; + /** + * Attribute Limits + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#attribute-limits + */ + public const OTEL_ATTRIBUTE_COUNT_LIMIT = 128; + public const OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT = PHP_INT_MAX; + /** + * Span Limits + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#span-limits + */ + public const OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT = 128; + public const OTEL_SPAN_EVENT_COUNT_LIMIT = 128; + public const OTEL_SPAN_LINK_COUNT_LIMIT = 128; + public const OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT = 128; + public const OTEL_LINK_ATTRIBUTE_COUNT_LIMIT = 128; + /** + * LogRecord Limits + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#logrecord-limits + */ + public const OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT = PHP_INT_MAX; + public const OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT = 128; + /** + * OTLP Exporter + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#configuration-options + */ + // Endpoint + public const OTEL_EXPORTER_OTLP_ENDPOINT = 'http://localhost:4318'; + public const OTEL_EXPORTER_OTLP_TRACES_ENDPOINT = 'http://localhost:4318'; + public const OTEL_EXPORTER_OTLP_METRICS_ENDPOINT = 'http://localhost:4318'; + public const OTEL_EXPORTER_OTLP_LOGS_ENDPOINT = 'http://localhost:4318'; + // Insecure + public const OTEL_EXPORTER_OTLP_INSECURE = 'false'; + public const OTEL_EXPORTER_OTLP_TRACES_INSECURE = 'false'; + public const OTEL_EXPORTER_OTLP_METRICS_INSECURE = 'false'; + public const OTEL_EXPORTER_OTLP_LOGS_INSECURE = 'false'; + // Timeout (seconds) + public const OTEL_EXPORTER_OTLP_TIMEOUT = 10; + public const OTEL_EXPORTER_OTLP_TRACES_TIMEOUT = 10; + public const OTEL_EXPORTER_OTLP_METRICS_TIMEOUT = 10; + public const OTEL_EXPORTER_OTLP_LOGS_TIMEOUT = 10; + // Protocol + public const OTEL_EXPORTER_OTLP_PROTOCOL = 'http/protobuf'; + public const OTEL_EXPORTER_OTLP_TRACES_PROTOCOL = 'http/protobuf'; + public const OTEL_EXPORTER_OTLP_METRICS_PROTOCOL = 'http/protobuf'; + public const OTEL_EXPORTER_OTLP_LOGS_PROTOCOL = 'http/protobuf'; + /** + * Zipkin Exporter + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#zipkin-exporter + */ + public const OTEL_EXPORTER_ZIPKIN_ENDPOINT = 'http://localhost:9411/api/v2/spans'; + // Timeout (seconds) + public const OTEL_EXPORTER_ZIPKIN_TIMEOUT = 10; + /** + * Prometheus Exporter + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#prometheus-exporter + */ + public const OTEL_EXPORTER_PROMETHEUS_HOST = '0.0.0.0'; + public const OTEL_EXPORTER_PROMETHEUS_PORT = 9464; + /** + * Exporter Selection + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#exporter-selection + */ + public const OTEL_TRACES_EXPORTER = 'otlp'; + public const OTEL_METRICS_EXPORTER = 'otlp'; + public const OTEL_LOGS_EXPORTER = 'otlp'; + /** + * Metrics SDK Configuration + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#metrics-sdk-configuration + */ + public const OTEL_METRICS_EXEMPLAR_FILTER = 'with_sampled_trace'; + public const OTEL_METRIC_EXPORT_INTERVAL = 60000; + public const OTEL_METRIC_EXPORT_TIMEOUT = 30000; + public const OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE = 'cumulative'; + public const OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION = 'explicit_bucket_histogram'; + /** + * Language Specific Environment Variables + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#language-specific-environment-variables + */ + public const OTEL_PHP_TRACES_PROCESSOR = 'batch'; + public const OTEL_PHP_DETECTORS = 'all'; + public const OTEL_PHP_AUTOLOAD_ENABLED = 'false'; + public const OTEL_PHP_INTERNAL_METRICS_ENABLED = 'false'; + public const OTEL_PHP_DISABLED_INSTRUMENTATIONS = []; + public const OTEL_PHP_LOGS_PROCESSOR = 'batch'; + public const OTEL_PHP_LOG_DESTINATION = 'default'; +} diff --git a/vendor/open-telemetry/sdk/Common/Configuration/KnownValues.php b/vendor/open-telemetry/sdk/Common/Configuration/KnownValues.php new file mode 100644 index 000000000..8975b20f9 --- /dev/null +++ b/vendor/open-telemetry/sdk/Common/Configuration/KnownValues.php @@ -0,0 +1,208 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\SDK\Common\Configuration; + +use Psr\Log\LogLevel; + +/** + * "Known values" for OpenTelemetry configurataion variables. + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md + * Notice: Values specific to the PHP SDK have been added + */ +interface KnownValues +{ + public const VALUE_TRUE = 'true'; + public const VALUE_FALSE = 'false'; + public const VALUE_ON = 'on'; + public const VALUE_OFF = 'off'; + public const VALUE_1 = '1'; + public const VALUE_0 = '0'; + public const VALUE_ALL = 'all'; + public const VALUE_NONE = 'none'; + public const VALUE_TRACECONTEXT = 'tracecontext'; + public const VALUE_BAGGAGE = 'baggage'; + public const VALUE_B3 = 'b3'; + public const VALUE_B3_MULTI = 'b3multi'; + public const VALUE_XRAY = 'xray'; + public const VALUE_OTTRACE = 'ottrace'; + public const VALUE_ALWAYS_ON = 'always_on'; + public const VALUE_ALWAYS_OFF = 'always_off'; + public const VALUE_TRACE_ID_RATIO = 'traceidratio'; + public const VALUE_PARENT_BASED_ALWAYS_ON = 'parentbased_always_on'; + public const VALUE_PARENT_BASED_ALWAYS_OFF = 'parentbased_always_off'; + public const VALUE_PARENT_BASED_TRACE_ID_RATIO = 'parentbased_traceidratio'; + public const VALUE_GZIP = 'gzip'; + public const VALUE_GRPC = 'grpc'; + public const VALUE_HTTP_PROTOBUF = 'http/protobuf'; + public const VALUE_HTTP_JSON = 'http/json'; + public const VALUE_HTTP_NDJSON = 'http/ndjson'; + public const VALUE_OTLP = 'otlp'; + public const VALUE_ZIPKIN = 'zipkin'; + public const VALUE_PROMETHEUS = 'prometheus'; + public const VALUE_WITH_SAMPLED_TRACE = 'with_sampled_trace'; + public const VALUE_BATCH = 'batch'; + public const VALUE_SIMPLE = 'simple'; + public const VALUE_NOOP = 'noop'; + public const VALUE_LOG_EMERGENCY = LogLevel::EMERGENCY; + public const VALUE_LOG_ALERT = LogLevel::ALERT; + public const VALUE_LOG_CRITICAL = LogLevel::CRITICAL; + public const VALUE_LOG_ERROR = LogLevel::ERROR; + public const VALUE_LOG_WARNING = LogLevel::WARNING; + public const VALUE_LOG_NOTICE = LogLevel::NOTICE; + public const VALUE_LOG_INFO = LogLevel::INFO; + public const VALUE_LOG_DEBUG = LogLevel::DEBUG; + public const VALUE_TEMPORALITY_CUMULATIVE = 'cumulative'; + public const VALUE_TEMPORALITY_DELTA = 'delta'; + public const VALUE_TEMPORALITY_LOW_MEMORY = 'lowmemory'; + public const VALUE_HISTOGRAM_AGGREGATION_EXPLICIT = 'explicit_bucket_histogram'; + public const VALUE_HISTOGRAM_AGGREGATION_BASE2_EXPONENTIAL = 'base2_exponential_bucket_histogram'; + + public const VALUES_BOOLEAN = [ + self::VALUE_TRUE, + self::VALUE_FALSE, + ]; + + public const VALUES_COMPRESSION= [ + self::VALUE_GZIP, + self::VALUE_NONE, + ]; + + public const VALUES_OTLP_PROTOCOL = [ + self::VALUE_GRPC, + self::VALUE_HTTP_PROTOBUF, + self::VALUE_HTTP_JSON, + ]; + + public const VALUES_TEMPORALITY_PREFERENCE = [ + self::VALUE_TEMPORALITY_CUMULATIVE, + self::VALUE_TEMPORALITY_DELTA, + self::VALUE_TEMPORALITY_LOW_MEMORY, + ]; + + public const VALUES_HISTOGRAM_AGGREGATION = [ + self::VALUE_HISTOGRAM_AGGREGATION_EXPLICIT, + self::VALUE_HISTOGRAM_AGGREGATION_BASE2_EXPONENTIAL, + ]; + + /** + * General SDK Configuration + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#general-sdk-configuration + */ + public const OTEL_LOG_LEVEL = [ + self::VALUE_LOG_EMERGENCY, + self::VALUE_LOG_ALERT, + self::VALUE_LOG_CRITICAL, + self::VALUE_LOG_ERROR, + self::VALUE_LOG_WARNING, + self::VALUE_LOG_NOTICE, + self::VALUE_LOG_INFO, + self::VALUE_LOG_DEBUG, + ]; + public const OTEL_PROPAGATORS = [ + self::VALUE_TRACECONTEXT, // W3C Trace Context + self::VALUE_BAGGAGE, // W3C Baggage + self::VALUE_B3, // B3 Single + self::VALUE_B3_MULTI, // B3 Multi + self::VALUE_XRAY, // AWS X-Ray (third party) + self::VALUE_OTTRACE, // OT Trace (third party) + self::VALUE_NONE, // No automatically configured propagator. + ]; + public const OTEL_TRACES_SAMPLER = [ + self::VALUE_ALWAYS_ON, + self::VALUE_ALWAYS_OFF, + self::VALUE_TRACE_ID_RATIO, + self::VALUE_PARENT_BASED_ALWAYS_ON, + self::VALUE_PARENT_BASED_ALWAYS_OFF, + self::VALUE_PARENT_BASED_TRACE_ID_RATIO, + self::VALUE_XRAY, + ]; + /** + * OTLP Exporter + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#configuration-options + */ + // Insecure + public const OTEL_EXPORTER_OTLP_INSECURE = self::VALUES_BOOLEAN; + public const OTEL_EXPORTER_OTLP_TRACES_INSECURE = self::VALUES_BOOLEAN; + public const OTEL_EXPORTER_OTLP_METRICS_INSECURE = self::VALUES_BOOLEAN; + // Compression + public const OTEL_EXPORTER_OTLP_COMPRESSION = self::VALUES_COMPRESSION; + public const OTEL_EXPORTER_OTLP_TRACES_COMPRESSION = self::VALUES_COMPRESSION; + public const OTEL_EXPORTER_OTLP_METRICS_COMPRESSION = self::VALUES_COMPRESSION; + // Protocol + public const OTEL_EXPORTER_OTLP_PROTOCOL = self::VALUES_OTLP_PROTOCOL; + public const OTEL_EXPORTER_OTLP_TRACES_PROTOCOL = self::VALUES_OTLP_PROTOCOL; + public const OTEL_EXPORTER_OTLP_METRICS_PROTOCOL = self::VALUES_OTLP_PROTOCOL; + /** + * Exporter Selection + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#exporter-selection + */ + public const OTEL_TRACES_EXPORTER = [ + self::VALUE_OTLP, + self::VALUE_ZIPKIN, + self::VALUE_NONE, + ]; + public const OTEL_METRICS_EXPORTER = [ + self::VALUE_OTLP, + self::VALUE_PROMETHEUS, + self::VALUE_NONE, + ]; + public const OTEL_LOGS_EXPORTER = [ + self::VALUE_OTLP, + self::VALUE_NONE, + ]; + /** + * Metrics SDK Configuration + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#metrics-sdk-configuration + */ + public const OTEL_METRICS_EXEMPLAR_FILTER = [ + self::VALUE_WITH_SAMPLED_TRACE, + self::VALUE_ALL, + self::VALUE_NONE, + ]; + /** + * Language Specific Environment Variables + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#language-specific-environment-variables + */ + public const OTEL_PHP_TRACES_PROCESSOR = [ + self::VALUE_BATCH, + self::VALUE_SIMPLE, + self::VALUE_NOOP, + self::VALUE_NONE, + ]; + public const OTEL_PHP_AUTOLOAD_ENABLED = self::VALUES_BOOLEAN; + public const VALUE_ERROR_LOG = 'error_log'; + public const VALUE_STDERR = 'stderr'; + public const VALUE_STDOUT = 'stdout'; + public const VALUE_PSR3 = 'psr3'; + public const VALUE_EMPTY = ''; + public const VALUE_DETECTORS_ENVIRONMENT = 'env'; + public const VALUE_DETECTORS_HOST = 'host'; + public const VALUE_DETECTORS_OS = 'os'; + public const VALUE_DETECTORS_PROCESS = 'process'; + public const VALUE_DETECTORS_PROCESS_RUNTIME = 'process_runtime'; + public const VALUE_DETECTORS_SDK = 'sdk'; + public const VALUE_DETECTORS_SDK_PROVIDED = 'sdk_provided'; + public const VALUE_DETECTORS_COMPOSER = 'composer'; + public const OTEL_PHP_DETECTORS = [ + self::VALUE_ALL, + self::VALUE_DETECTORS_ENVIRONMENT, + self::VALUE_DETECTORS_HOST, + self::VALUE_DETECTORS_OS, + self::VALUE_DETECTORS_PROCESS, + self::VALUE_DETECTORS_PROCESS_RUNTIME, + self::VALUE_DETECTORS_SDK, + self::VALUE_DETECTORS_SDK_PROVIDED, + self::VALUE_DETECTORS_COMPOSER, + self::VALUE_NONE, + ]; + public const OTEL_PHP_LOG_DESTINATION = [ + self::VALUE_ERROR_LOG, + self::VALUE_STDERR, + self::VALUE_STDOUT, + self::VALUE_PSR3, + self::VALUE_EMPTY, + self::VALUE_NONE, + ]; +} diff --git a/vendor/open-telemetry/sdk/Common/Configuration/Parser/BooleanParser.php b/vendor/open-telemetry/sdk/Common/Configuration/Parser/BooleanParser.php new file mode 100644 index 000000000..4141c61ef --- /dev/null +++ b/vendor/open-telemetry/sdk/Common/Configuration/Parser/BooleanParser.php @@ -0,0 +1,34 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\SDK\Common\Configuration\Parser; + +use InvalidArgumentException; + +class BooleanParser +{ + private const TRUE_VALUE = 'true'; + private const FALSE_VALUE = 'false'; + + /** + * @param string|bool $value + */ + public static function parse($value): bool + { + if (is_bool($value)) { + return $value; + } + if (strtolower($value) === self::TRUE_VALUE) { + return true; + } + + if (strtolower($value) === self::FALSE_VALUE) { + return false; + } + + throw new InvalidArgumentException( + sprintf('Value "%s" is a non-boolean value', $value) + ); + } +} diff --git a/vendor/open-telemetry/sdk/Common/Configuration/Parser/ListParser.php b/vendor/open-telemetry/sdk/Common/Configuration/Parser/ListParser.php new file mode 100644 index 000000000..f27b16597 --- /dev/null +++ b/vendor/open-telemetry/sdk/Common/Configuration/Parser/ListParser.php @@ -0,0 +1,28 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\SDK\Common\Configuration\Parser; + +class ListParser +{ + private const DEFAULT_SEPARATOR = ','; + + /** + * @param string|array $value + */ + public static function parse($value): array + { + if (is_array($value)) { + return $value; + } + if (trim($value) === '') { + return []; + } + + return array_map( + fn ($value) => trim($value), + explode(self::DEFAULT_SEPARATOR, $value) + ); + } +} diff --git a/vendor/open-telemetry/sdk/Common/Configuration/Parser/MapParser.php b/vendor/open-telemetry/sdk/Common/Configuration/Parser/MapParser.php new file mode 100644 index 000000000..273d57c87 --- /dev/null +++ b/vendor/open-telemetry/sdk/Common/Configuration/Parser/MapParser.php @@ -0,0 +1,45 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\SDK\Common\Configuration\Parser; + +use InvalidArgumentException; + +class MapParser +{ + private const VARIABLE_SEPARATOR = ','; + private const KEY_VALUE_SEPARATOR = '='; + + public static function parse($value): array + { + if (is_array($value)) { + return $value; + } + $result = []; + + if (null === $value || trim($value) === '') { + return $result; + } + + foreach (explode(self::VARIABLE_SEPARATOR, $value) as $pair) { + self::validateKeyValuePair($pair); + + [$key, $value] = explode(self::KEY_VALUE_SEPARATOR, $pair, 2); + $result[trim($key)] = trim($value); + } + + return $result; + } + + private static function validateKeyValuePair(string $pair) + { + if (strpos($pair, self::KEY_VALUE_SEPARATOR) === false) { + throw new InvalidArgumentException(sprintf( + 'Key-Value pair "%s" does not contain separator "%s"', + $pair, + self::KEY_VALUE_SEPARATOR + )); + } + } +} diff --git a/vendor/open-telemetry/sdk/Common/Configuration/Parser/RatioParser.php b/vendor/open-telemetry/sdk/Common/Configuration/Parser/RatioParser.php new file mode 100644 index 000000000..f0fe32100 --- /dev/null +++ b/vendor/open-telemetry/sdk/Common/Configuration/Parser/RatioParser.php @@ -0,0 +1,38 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\SDK\Common\Configuration\Parser; + +use InvalidArgumentException; +use RangeException; + +class RatioParser +{ + private const MAX_VALUE = 1; + private const MIN_VALUE = 0; + + public static function parse($value): float + { + if (filter_var($value, FILTER_VALIDATE_FLOAT) === false) { + throw new InvalidArgumentException( + sprintf('Value "%s" contains non-numeric value', $value) + ); + } + + $result = (float) $value; + + if ($result > self::MAX_VALUE || $result < self::MIN_VALUE) { + throw new RangeException( + sprintf( + 'Value must not be lower than %s or higher than %s. Given: %s', + self::MIN_VALUE, + self::MAX_VALUE, + $value + ) + ); + } + + return $result; + } +} diff --git a/vendor/open-telemetry/sdk/Common/Configuration/Resolver/CompositeResolver.php b/vendor/open-telemetry/sdk/Common/Configuration/Resolver/CompositeResolver.php new file mode 100644 index 000000000..b72400b01 --- /dev/null +++ b/vendor/open-telemetry/sdk/Common/Configuration/Resolver/CompositeResolver.php @@ -0,0 +1,68 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\SDK\Common\Configuration\Resolver; + +use OpenTelemetry\SDK\Common\Configuration\Configuration; + +/** + * @interal + */ +class CompositeResolver +{ + // @var array<ResolverInterface> + private array $resolvers = []; + + public static function instance(): self + { + static $instance; + $instance ??= new self([ + new PhpIniResolver(), + new EnvironmentResolver(), + ]); + + return $instance; + } + + public function __construct($resolvers) + { + foreach ($resolvers as $resolver) { + $this->addResolver($resolver); + } + } + + public function addResolver(ResolverInterface $resolver): void + { + $this->resolvers[] = $resolver; + } + + public function getResolvers(): array + { + return $this->resolvers; + } + + public function resolve(string $variableName, $default = '') + { + foreach ($this->resolvers as $resolver) { + if ($resolver->hasVariable($variableName)) { + return $resolver->retrieveValue($variableName); + } + } + + return Configuration::isEmpty($default) + ? Configuration::getDefault($variableName) + : $default; + } + + public function hasVariable(string $variableName): bool + { + foreach ($this->resolvers as $resolver) { + if ($resolver->hasVariable($variableName)) { + return true; + } + } + + return false; + } +} diff --git a/vendor/open-telemetry/sdk/Common/Configuration/Resolver/EnvironmentResolver.php b/vendor/open-telemetry/sdk/Common/Configuration/Resolver/EnvironmentResolver.php new file mode 100644 index 000000000..453f98e39 --- /dev/null +++ b/vendor/open-telemetry/sdk/Common/Configuration/Resolver/EnvironmentResolver.php @@ -0,0 +1,40 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\SDK\Common\Configuration\Resolver; + +use OpenTelemetry\SDK\Common\Configuration\Configuration; + +/** + * @internal + */ +class EnvironmentResolver implements ResolverInterface +{ + public function hasVariable(string $variableName): bool + { + if (!Configuration::isEmpty($_SERVER[$variableName] ?? null)) { + return true; + } + $env = getenv($variableName); + if ($env === false) { + return false; + } + + return !Configuration::isEmpty($env); + } + + /** + * @psalm-suppress InvalidReturnStatement + * @psalm-suppress InvalidReturnType + */ + public function retrieveValue(string $variableName) + { + $value = getenv($variableName); + if ($value === false) { + $value = $_SERVER[$variableName] ?? null; + } + + return $value; + } +} diff --git a/vendor/open-telemetry/sdk/Common/Configuration/Resolver/PhpIniAccessor.php b/vendor/open-telemetry/sdk/Common/Configuration/Resolver/PhpIniAccessor.php new file mode 100644 index 000000000..a12b507e8 --- /dev/null +++ b/vendor/open-telemetry/sdk/Common/Configuration/Resolver/PhpIniAccessor.php @@ -0,0 +1,18 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\SDK\Common\Configuration\Resolver; + +class PhpIniAccessor +{ + /** + * Mockable accessor for php.ini values + * @internal + * @return array|false|string + */ + public function get(string $variableName) + { + return get_cfg_var($variableName); + } +} diff --git a/vendor/open-telemetry/sdk/Common/Configuration/Resolver/PhpIniResolver.php b/vendor/open-telemetry/sdk/Common/Configuration/Resolver/PhpIniResolver.php new file mode 100644 index 000000000..c9a8f3b4e --- /dev/null +++ b/vendor/open-telemetry/sdk/Common/Configuration/Resolver/PhpIniResolver.php @@ -0,0 +1,41 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\SDK\Common\Configuration\Resolver; + +use OpenTelemetry\SDK\Common\Configuration\Configuration; + +/** + * @interal + * @psalm-suppress TypeDoesNotContainType + */ +class PhpIniResolver implements ResolverInterface +{ + private PhpIniAccessor $accessor; + + public function __construct(?PhpIniAccessor $accessor = null) + { + $this->accessor = $accessor ?? new PhpIniAccessor(); + } + + public function retrieveValue(string $variableName) + { + $value = $this->accessor->get($variableName) ?: ''; + if (is_array($value)) { + return implode(',', $value); + } + + return $value; + } + + public function hasVariable(string $variableName): bool + { + $value = $this->accessor->get($variableName); + if ($value === []) { + return false; + } + + return $value !== false && !Configuration::isEmpty($value); + } +} diff --git a/vendor/open-telemetry/sdk/Common/Configuration/Resolver/ResolverInterface.php b/vendor/open-telemetry/sdk/Common/Configuration/Resolver/ResolverInterface.php new file mode 100644 index 000000000..4e88f3ff6 --- /dev/null +++ b/vendor/open-telemetry/sdk/Common/Configuration/Resolver/ResolverInterface.php @@ -0,0 +1,15 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\SDK\Common\Configuration\Resolver; + +interface ResolverInterface +{ + /** + * @return mixed + */ + public function retrieveValue(string $variableName); + + public function hasVariable(string $variableName): bool; +} diff --git a/vendor/open-telemetry/sdk/Common/Configuration/ValueTypes.php b/vendor/open-telemetry/sdk/Common/Configuration/ValueTypes.php new file mode 100644 index 000000000..64a69f6a7 --- /dev/null +++ b/vendor/open-telemetry/sdk/Common/Configuration/ValueTypes.php @@ -0,0 +1,133 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\SDK\Common\Configuration; + +/** + * Environment variables defined by the OpenTelemetry specification and language specific variables for the PHP SDK. + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md + */ +interface ValueTypes +{ + /** + * General SDK Configuration + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#general-sdk-configuration + */ + public const OTEL_RESOURCE_ATTRIBUTES = VariableTypes::MAP; + public const OTEL_SERVICE_NAME = VariableTypes::STRING; + public const OTEL_LOG_LEVEL = VariableTypes::ENUM; + public const OTEL_PROPAGATORS = VariableTypes::LIST; + public const OTEL_TRACES_SAMPLER = VariableTypes::STRING; + public const OTEL_TRACES_SAMPLER_ARG = VariableTypes::MIXED; + /** + * Batch Span Processor + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#batch-span-processor + */ + public const OTEL_BSP_SCHEDULE_DELAY = VariableTypes::INTEGER; + public const OTEL_BSP_EXPORT_TIMEOUT = VariableTypes::INTEGER; + public const OTEL_BSP_MAX_QUEUE_SIZE = VariableTypes::INTEGER; + public const OTEL_BSP_MAX_EXPORT_BATCH_SIZE = VariableTypes::INTEGER; + /** + * Batch LogRecord Processor + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#batch-logrecord-processor + */ + public const OTEL_BLRP_SCHEDULE_DELAY = VariableTypes::INTEGER; + public const OTEL_BLRP_EXPORT_TIMEOUT = VariableTypes::INTEGER; + public const OTEL_BLRP_MAX_QUEUE_SIZE = VariableTypes::INTEGER; + public const OTEL_BLRP_MAX_EXPORT_BATCH_SIZE = VariableTypes::INTEGER; + /** + * Attribute Limits + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#attribute-limits + */ + public const OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT = VariableTypes::INTEGER; + public const OTEL_ATTRIBUTE_COUNT_LIMIT = VariableTypes::INTEGER; + /** + * Span Limits + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#span-limits + */ + public const OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT = VariableTypes::INTEGER; + public const OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT = VariableTypes::INTEGER; + public const OTEL_SPAN_EVENT_COUNT_LIMIT = VariableTypes::INTEGER; + public const OTEL_SPAN_LINK_COUNT_LIMIT = VariableTypes::INTEGER; + public const OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT = VariableTypes::INTEGER; + public const OTEL_LINK_ATTRIBUTE_COUNT_LIMIT = VariableTypes::INTEGER; + /** + * LogRecord Limits + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#logrecord-limits + */ + public const OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT = VariableTypes::INTEGER; + public const OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT = VariableTypes::INTEGER; + /** + * OTLP Exporter + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#configuration-options + */ + // Endpoint + public const OTEL_EXPORTER_OTLP_ENDPOINT = VariableTypes::STRING; + public const OTEL_EXPORTER_OTLP_TRACES_ENDPOINT = VariableTypes::STRING; + public const OTEL_EXPORTER_OTLP_METRICS_ENDPOINT = VariableTypes::STRING; + // Insecure + public const OTEL_EXPORTER_OTLP_INSECURE = VariableTypes::BOOL; + public const OTEL_EXPORTER_OTLP_TRACES_INSECURE = VariableTypes::BOOL; + public const OTEL_EXPORTER_OTLP_METRICS_INSECURE = VariableTypes::BOOL; + // Certificate File + public const OTEL_EXPORTER_OTLP_CERTIFICATE = VariableTypes::STRING; + public const OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE = VariableTypes::STRING; + public const OTEL_EXPORTER_OTLP_METRICS_CERTIFICATE = VariableTypes::STRING; + // Headers + public const OTEL_EXPORTER_OTLP_HEADERS = VariableTypes::MAP; + public const OTEL_EXPORTER_OTLP_TRACES_HEADERS = VariableTypes::MAP; + public const OTEL_EXPORTER_OTLP_METRICS_HEADERS = VariableTypes::MAP; + // Compression + public const OTEL_EXPORTER_OTLP_COMPRESSION = VariableTypes::ENUM; + public const OTEL_EXPORTER_OTLP_TRACES_COMPRESSION = VariableTypes::ENUM; + public const OTEL_EXPORTER_OTLP_METRICS_COMPRESSION = VariableTypes::ENUM; + // Timeout + public const OTEL_EXPORTER_OTLP_TIMEOUT = VariableTypes::INTEGER; + public const OTEL_EXPORTER_OTLP_TRACES_TIMEOUT = VariableTypes::INTEGER; + public const OTEL_EXPORTER_OTLP_METRICS_TIMEOUT = VariableTypes::INTEGER; + // Protocol + public const OTEL_EXPORTER_OTLP_PROTOCOL = VariableTypes::ENUM; + public const OTEL_EXPORTER_OTLP_TRACES_PROTOCOL = VariableTypes::ENUM; + public const OTEL_EXPORTER_OTLP_METRICS_PROTOCOL = VariableTypes::ENUM; + /** + * Zipkin Exporter + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#zipkin-exporter + */ + public const OTEL_EXPORTER_ZIPKIN_ENDPOINT = VariableTypes::STRING; + public const OTEL_EXPORTER_ZIPKIN_TIMEOUT = VariableTypes::INTEGER; + public const OTEL_EXPORTER_ZIPKIN_PROTOCOL = VariableTypes::STRING; + /** + * Prometheus Exporter + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#prometheus-exporter + */ + public const OTEL_EXPORTER_PROMETHEUS_HOST = VariableTypes::STRING; + public const OTEL_EXPORTER_PROMETHEUS_PORT = VariableTypes::INTEGER; + /** + * Exporter Selection + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#exporter-selection + */ + public const OTEL_TRACES_EXPORTER = VariableTypes::LIST; + public const OTEL_METRICS_EXPORTER = VariableTypes::LIST; + public const OTEL_LOGS_EXPORTER = VariableTypes::LIST; + /** + * Metrics SDK Configuration + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#metrics-sdk-configuration + */ + public const OTEL_METRICS_EXEMPLAR_FILTER = VariableTypes::ENUM; + public const OTEL_METRIC_EXPORT_INTERVAL = VariableTypes::INTEGER; + public const OTEL_METRIC_EXPORT_TIMEOUT = VariableTypes::INTEGER; + public const OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE = VariableTypes::ENUM; + public const OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION = VariableTypes::ENUM; + /** + * Language Specific Environment Variables + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#language-specific-environment-variables + */ + public const OTEL_PHP_TRACES_PROCESSOR = VariableTypes::ENUM; + public const OTEL_PHP_LOGS_PROCESSOR = VariableTypes::LIST; + public const OTEL_PHP_DETECTORS = VariableTypes::LIST; + public const OTEL_PHP_AUTOLOAD_ENABLED = VariableTypes::BOOL; + public const OTEL_PHP_LOG_DESTINATION = VariableTypes::ENUM; + public const OTEL_PHP_INTERNAL_METRICS_ENABLED = VariableTypes::BOOL; + public const OTEL_PHP_DISABLED_INSTRUMENTATIONS = VariableTypes::LIST; +} diff --git a/vendor/open-telemetry/sdk/Common/Configuration/VariableTypes.php b/vendor/open-telemetry/sdk/Common/Configuration/VariableTypes.php new file mode 100644 index 000000000..471632e16 --- /dev/null +++ b/vendor/open-telemetry/sdk/Common/Configuration/VariableTypes.php @@ -0,0 +1,62 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\SDK\Common\Configuration; + +interface VariableTypes +{ + /** + * A single boolean value represented as a string or integer ('true', 'false', 0, 1) + * example: value1 + */ + public const BOOL = 'bool'; + + /** + * A single string value + * example: value1 + */ + public const STRING = 'string'; + + /** + * A single integer value + * example: 5000 + */ + public const INTEGER = 'integer'; + + /** + * A single float value + * example: 10.5 + */ + public const FLOAT = 'float'; + + /** + * A single float value between 0.0 and 1.0 + * example: 0.5 + */ + public const RATIO = 'ratio'; + + /** + * A single string value from a fixed list of values + * example values: value1, value2, value3 + * example: value1 + */ + public const ENUM = 'enum'; + + /** + * A comma separated list of single string values + * example: value1,value2,value3 + */ + public const LIST = 'list'; + + /** + * A comma separated list of key-value pairs + * example: key1=value1,key2=value2 + */ + public const MAP = 'map'; + + /** + * Values of mixed type + */ + public const MIXED = 'mixed'; +} diff --git a/vendor/open-telemetry/sdk/Common/Configuration/Variables.php b/vendor/open-telemetry/sdk/Common/Configuration/Variables.php new file mode 100644 index 000000000..d0bb3c8ab --- /dev/null +++ b/vendor/open-telemetry/sdk/Common/Configuration/Variables.php @@ -0,0 +1,142 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\SDK\Common\Configuration; + +/** + * Environment variables defined by the OpenTelemetry specification and language specific variables for the PHP SDK. + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md + */ +interface Variables +{ + /** + * General SDK Configuration + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#general-sdk-configuration + */ + public const OTEL_RESOURCE_ATTRIBUTES = 'OTEL_RESOURCE_ATTRIBUTES'; + public const OTEL_SERVICE_NAME = 'OTEL_SERVICE_NAME'; + public const OTEL_LOG_LEVEL = 'OTEL_LOG_LEVEL'; + public const OTEL_PROPAGATORS = 'OTEL_PROPAGATORS'; + public const OTEL_TRACES_SAMPLER = 'OTEL_TRACES_SAMPLER'; + public const OTEL_TRACES_SAMPLER_ARG = 'OTEL_TRACES_SAMPLER_ARG'; + public const OTEL_SDK_DISABLED = 'OTEL_SDK_DISABLED'; + /** + * Batch Span Processor + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#batch-span-processor + */ + public const OTEL_BSP_SCHEDULE_DELAY = 'OTEL_BSP_SCHEDULE_DELAY'; + public const OTEL_BSP_EXPORT_TIMEOUT = 'OTEL_BSP_EXPORT_TIMEOUT'; + public const OTEL_BSP_MAX_QUEUE_SIZE = 'OTEL_BSP_MAX_QUEUE_SIZE'; + public const OTEL_BSP_MAX_EXPORT_BATCH_SIZE = 'OTEL_BSP_MAX_EXPORT_BATCH_SIZE'; + /** + * Batch LogRecord Processor + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#batch-logrecord-processor + */ + public const OTEL_BLRP_SCHEDULE_DELAY = 'OTEL_BLRP_SCHEDULE_DELAY'; + public const OTEL_BLRP_EXPORT_TIMEOUT = 'OTEL_BLRP_EXPORT_TIMEOUT'; + public const OTEL_BLRP_MAX_QUEUE_SIZE = 'OTEL_BLRP_MAX_QUEUE_SIZE'; + public const OTEL_BLRP_MAX_EXPORT_BATCH_SIZE = 'OTEL_BLRP_MAX_EXPORT_BATCH_SIZE'; + /** + * Attribute Limits + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#attribute-limits + */ + public const OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT = 'OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT'; + public const OTEL_ATTRIBUTE_COUNT_LIMIT = 'OTEL_ATTRIBUTE_COUNT_LIMIT'; + /** + * LogRecord limits + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#logrecord-limits + */ + public const OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT = 'OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT'; + public const OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT = 'OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT'; + /** + * Span Limits + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#span-limits + */ + public const OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT = 'OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT'; + public const OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT = 'OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT'; + public const OTEL_SPAN_EVENT_COUNT_LIMIT = 'OTEL_SPAN_EVENT_COUNT_LIMIT'; + public const OTEL_SPAN_LINK_COUNT_LIMIT = 'OTEL_SPAN_LINK_COUNT_LIMIT'; + public const OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT = 'OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT'; + public const OTEL_LINK_ATTRIBUTE_COUNT_LIMIT = 'OTEL_LINK_ATTRIBUTE_COUNT_LIMIT'; + /** + * OTLP Exporter + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#configuration-options + */ + // Endpoint + public const OTEL_EXPORTER_OTLP_ENDPOINT = 'OTEL_EXPORTER_OTLP_ENDPOINT'; + public const OTEL_EXPORTER_OTLP_TRACES_ENDPOINT = 'OTEL_EXPORTER_OTLP_TRACES_ENDPOINT'; + public const OTEL_EXPORTER_OTLP_METRICS_ENDPOINT = 'OTEL_EXPORTER_OTLP_METRICS_ENDPOINT'; + public const OTEL_EXPORTER_OTLP_LOGS_ENDPOINT = 'OTEL_EXPORTER_OTLP_LOGS_ENDPOINT'; + // Insecure + public const OTEL_EXPORTER_OTLP_INSECURE = 'OTEL_EXPORTER_OTLP_INSECURE'; + public const OTEL_EXPORTER_OTLP_TRACES_INSECURE = 'OTEL_EXPORTER_OTLP_TRACES_INSECURE'; + public const OTEL_EXPORTER_OTLP_METRICS_INSECURE = 'OTEL_EXPORTER_OTLP_METRICS_INSECURE'; + public const OTEL_EXPORTER_OTLP_LOGS_INSECURE = 'OTEL_EXPORTER_OTLP_LOGS_INSECURE'; + // Certificate File + public const OTEL_EXPORTER_OTLP_CERTIFICATE = 'OTEL_EXPORTER_OTLP_CERTIFICATE'; + public const OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE = 'OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE'; + public const OTEL_EXPORTER_OTLP_METRICS_CERTIFICATE = 'OTEL_EXPORTER_OTLP_METRICS_CERTIFICATE'; + public const OTEL_EXPORTER_OTLP_LOGS_CERTIFICATE = 'OTEL_EXPORTER_OTLP_LOGS_CERTIFICATE'; + // Headers + public const OTEL_EXPORTER_OTLP_HEADERS = 'OTEL_EXPORTER_OTLP_HEADERS'; + public const OTEL_EXPORTER_OTLP_TRACES_HEADERS = 'OTEL_EXPORTER_OTLP_TRACES_HEADERS'; + public const OTEL_EXPORTER_OTLP_METRICS_HEADERS = 'OTEL_EXPORTER_OTLP_METRICS_HEADERS'; + public const OTEL_EXPORTER_OTLP_LOGS_HEADERS = 'OTEL_EXPORTER_OTLP_LOGS_HEADERS'; + // Compression + public const OTEL_EXPORTER_OTLP_COMPRESSION = 'OTEL_EXPORTER_OTLP_COMPRESSION'; + public const OTEL_EXPORTER_OTLP_TRACES_COMPRESSION = 'OTEL_EXPORTER_OTLP_TRACES_COMPRESSION'; + public const OTEL_EXPORTER_OTLP_METRICS_COMPRESSION = 'OTEL_EXPORTER_OTLP_METRICS_COMPRESSION'; + public const OTEL_EXPORTER_OTLP_LOGS_COMPRESSION = 'OTEL_EXPORTER_OTLP_LOGS_COMPRESSION'; + // Timeout + public const OTEL_EXPORTER_OTLP_TIMEOUT = 'OTEL_EXPORTER_OTLP_TIMEOUT'; + public const OTEL_EXPORTER_OTLP_TRACES_TIMEOUT = 'OTEL_EXPORTER_OTLP_TRACES_TIMEOUT'; + public const OTEL_EXPORTER_OTLP_METRICS_TIMEOUT = 'OTEL_EXPORTER_OTLP_METRICS_TIMEOUT'; + public const OTEL_EXPORTER_OTLP_LOGS_TIMEOUT = 'OTEL_EXPORTER_OTLP_LOGS_TIMEOUT'; + // Protocol + public const OTEL_EXPORTER_OTLP_PROTOCOL = 'OTEL_EXPORTER_OTLP_PROTOCOL'; + public const OTEL_EXPORTER_OTLP_TRACES_PROTOCOL = 'OTEL_EXPORTER_OTLP_TRACES_PROTOCOL'; + public const OTEL_EXPORTER_OTLP_METRICS_PROTOCOL = 'OTEL_EXPORTER_OTLP_METRICS_PROTOCOL'; + public const OTEL_EXPORTER_OTLP_LOGS_PROTOCOL = 'OTEL_EXPORTER_OTLP_LOGS_PROTOCOL'; + /** + * Zipkin Exporter + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#zipkin-exporter + */ + public const OTEL_EXPORTER_ZIPKIN_ENDPOINT = 'OTEL_EXPORTER_ZIPKIN_ENDPOINT'; + public const OTEL_EXPORTER_ZIPKIN_TIMEOUT = 'OTEL_EXPORTER_ZIPKIN_TIMEOUT'; + public const OTEL_EXPORTER_ZIPKIN_PROTOCOL = 'OTEL_EXPORTER_ZIPKIN_PROTOCOL'; + /** + * Prometheus Exporter + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#prometheus-exporter + */ + public const OTEL_EXPORTER_PROMETHEUS_HOST = 'OTEL_EXPORTER_PROMETHEUS_HOST'; + public const OTEL_EXPORTER_PROMETHEUS_PORT = 'OTEL_EXPORTER_PROMETHEUS_PORT'; + /** + * Exporter Selection + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#exporter-selection + */ + public const OTEL_TRACES_EXPORTER = 'OTEL_TRACES_EXPORTER'; + public const OTEL_METRICS_EXPORTER = 'OTEL_METRICS_EXPORTER'; + public const OTEL_LOGS_EXPORTER = 'OTEL_LOGS_EXPORTER'; + /** + * Metrics SDK Configuration + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#metrics-sdk-configuration + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#periodic-exporting-metricreader + */ + public const OTEL_METRICS_EXEMPLAR_FILTER = 'OTEL_METRICS_EXEMPLAR_FILTER'; + public const OTEL_METRIC_EXPORT_INTERVAL = 'OTEL_METRIC_EXPORT_INTERVAL'; + public const OTEL_METRIC_EXPORT_TIMEOUT = 'OTEL_METRIC_EXPORT_TIMEOUT'; + public const OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE = 'OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE'; + public const OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION = 'OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION'; + /** + * Language Specific Environment Variables + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#language-specific-environment-variables + */ + public const OTEL_PHP_TRACES_PROCESSOR = 'OTEL_PHP_TRACES_PROCESSOR'; + public const OTEL_PHP_LOGS_PROCESSOR = 'OTEL_PHP_LOGS_PROCESSOR'; + public const OTEL_PHP_LOG_DESTINATION = 'OTEL_PHP_LOG_DESTINATION'; + public const OTEL_PHP_DETECTORS = 'OTEL_PHP_DETECTORS'; + public const OTEL_PHP_AUTOLOAD_ENABLED = 'OTEL_PHP_AUTOLOAD_ENABLED'; + public const OTEL_PHP_INTERNAL_METRICS_ENABLED = 'OTEL_PHP_INTERNAL_METRICS_ENABLED'; //whether the SDK should emit its own metrics + public const OTEL_PHP_DISABLED_INSTRUMENTATIONS = 'OTEL_PHP_DISABLED_INSTRUMENTATIONS'; +} |