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.
Synopsis
Section titled “Synopsis”final class TelemetryExporterFactory
| Since | 3.2.0 |
| Source | TelemetryExporterFactory.php |
Constructor
Section titled “Constructor”__construct()
Section titled “__construct()”public function __construct(TelemetryConfig $config): mixed
| Parameter | Type | Description |
|---|---|---|
$config | TelemetryConfig |
Returns mixed
Methods
Section titled “Methods”| Method | Description |
|---|---|
inMemoryMetricExporter(): ?InMemoryExporter | The in-memory metric exporter, when one was built. |
inMemorySpanExporter(): ?InMemoryExporter | The in-memory span exporter, when one was built. |
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(). |
spanExporter(): SpanExporterInterface | Builds the span exporter named by telemetry.exporter. |
inMemoryMetricExporter()
Section titled “inMemoryMetricExporter()”public function inMemoryMetricExporter(): ?InMemoryExporter
The in-memory metric exporter, when one was built.
For tests.
Returns ?``InMemoryExporter
inMemorySpanExporter()
Section titled “inMemorySpanExporter()”public function inMemorySpanExporter(): ?InMemoryExporter
The in-memory span exporter, when one was built.
For tests.
Returns ?``InMemoryExporter
metricExporter()
Section titled “metricExporter()”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
spanExporter()
Section titled “spanExporter()”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