summaryrefslogtreecommitdiff
path: root/vendor/open-telemetry/sdk/Logs/ExporterFactory.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/open-telemetry/sdk/Logs/ExporterFactory.php')
-rw-r--r--vendor/open-telemetry/sdk/Logs/ExporterFactory.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/vendor/open-telemetry/sdk/Logs/ExporterFactory.php b/vendor/open-telemetry/sdk/Logs/ExporterFactory.php
new file mode 100644
index 000000000..2a560ae95
--- /dev/null
+++ b/vendor/open-telemetry/sdk/Logs/ExporterFactory.php
@@ -0,0 +1,29 @@
+<?php
+
+declare(strict_types=1);
+
+namespace OpenTelemetry\SDK\Logs;
+
+use InvalidArgumentException;
+use OpenTelemetry\SDK\Common\Configuration\Configuration;
+use OpenTelemetry\SDK\Common\Configuration\Variables;
+use OpenTelemetry\SDK\Logs\Exporter\NoopExporter;
+use OpenTelemetry\SDK\Registry;
+
+class ExporterFactory
+{
+ public function create(): LogRecordExporterInterface
+ {
+ $exporters = Configuration::getList(Variables::OTEL_LOGS_EXPORTER);
+ if (1 !== count($exporters)) {
+ throw new InvalidArgumentException(sprintf('Configuration %s requires exactly 1 exporter', Variables::OTEL_TRACES_EXPORTER));
+ }
+ $exporter = $exporters[0];
+ if ($exporter === 'none') {
+ return new NoopExporter();
+ }
+ $factory = Registry::logRecordExporterFactory($exporter);
+
+ return $factory->create();
+ }
+}