Skip to content

TelemetryConfig

The telemetry.* settings, read once and resolved into concrete values.

Every decision that depends on configuration or on the environment is made here, so the factories that build exporters and providers take plain values and can be exercised without touching process-wide config. That is the whole point of the separation: the interesting part of telemetry setup is which exporter and sampler you end up with, and testing that should not require mutating globals.

final readonly class TelemetryConfig

Since3.2.0
SourceTelemetryConfig.php
PropertyTypeDescription
$exportModestringreadonly.
$exporterstringreadonly.
$otlpEndpointstringreadonly.
$otlpHeadersarrayreadonly.
$otlpProtocolstringreadonly.
$resourceAttributesarrayreadonly.
$samplingRatiofloatreadonly.
$samplingStrategystringreadonly.
$serviceNamestringreadonly.
$serviceNamespacestringreadonly.

public function __construct(string $serviceName, string $serviceNamespace, array<string, mixed> $resourceAttributes, string $exporter, string $exportMode, string $samplingStrategy, float $samplingRatio, string $otlpEndpoint, string $otlpProtocol, array<string, string> $otlpHeaders): mixed

Header name => value, already stringified.

ParameterTypeDescription
$serviceNamestring
$serviceNamespacestring
$resourceAttributesarray``<``string``, ``mixed``>Extra resource attributes.
$exporterstring
$exportModestring
$samplingStrategystring
$samplingRatiofloat
$otlpEndpointstring
$otlpProtocolstring
$otlpHeadersarray``<``string``, ``string``>Header name => value, already stringified.

Returns mixed

MethodDescription
fromConfig(): TelemetryConfigRead the settings, resolving the defaults that depend on the environment.

public static function fromConfig(): TelemetryConfig

Read the settings, resolving the defaults that depend on the environment.

The export mode defaults by runtime: batching only pays off when the process outlives the request. This is read during boot, before the Kernel has selected a runtime, so WorkerRuntimeInfo answers from auto-detection rather than from an installed runtime — which is correct, because plugins (including any contributing a runtime) have already registered.

Returns TelemetryConfig