Skip to content

TelemetryExporterFactory

Builds the span and metric exporters named by telemetry.exporter.

One instance per configuration, holding the in-memory exporters it created so a test can read back what was exported. An unrecognised exporter name falls back to the in-memory one rather than failing the provider, because disabling telemetry entirely over a typo is worse than exporting nowhere and saying so.

final class TelemetryExporterFactory

Since3.2.0
SourceTelemetryExporterFactory.php

public function __construct(TelemetryConfig $config): mixed

ParameterTypeDescription
$configTelemetryConfig

Returns mixed

MethodDescription
inMemoryMetricExporter(): ?InMemoryExporterThe in-memory metric exporter, when one was built.
inMemorySpanExporter(): ?InMemoryExporterThe in-memory span exporter, when one was built.
metricExporter(): MetricExporterInterfaceBuilds the metric exporter named by telemetry.exporter, on the same terms as TelemetryExporterFactory::spanExporter(); the in-memory result is retained for TelemetryExporterFactory::inMemoryMetricExporter().
spanExporter(): SpanExporterInterfaceBuilds the span exporter named by telemetry.exporter.

public function inMemoryMetricExporter(): ?InMemoryExporter

The in-memory metric exporter, when one was built.

For tests.

Returns ?``InMemoryExporter

public function inMemorySpanExporter(): ?InMemoryExporter

The in-memory span exporter, when one was built.

For tests.

Returns ?``InMemoryExporter

public function metricExporter(): MetricExporterInterface

Builds the metric exporter named by telemetry.exporter, on the same terms as TelemetryExporterFactory::spanExporter(); the in-memory result is retained for TelemetryExporterFactory::inMemoryMetricExporter().

Returns MetricExporterInterface

public function spanExporter(): SpanExporterInterface

Builds the span exporter named by telemetry.exporter.

none and any unrecognised name yield an in-memory exporter, which is retained for TelemetryExporterFactory::inMemorySpanExporter(); an unrecognised name is also logged at warning level. otlp bridges the OTLP settings into the OTEL_EXPORTER_OTLP_* environment before delegating to the SDK factory.

Returns SpanExporterInterface