use of io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider in project opentelemetry-java by open-telemetry.
the class SpanExporterConfiguration method configureSpanExporters.
// Visible for testing
static Map<String, SpanExporter> configureSpanExporters(ConfigProperties config, ClassLoader serviceClassLoader, MeterProvider meterProvider, BiFunction<? super SpanExporter, ConfigProperties, ? extends SpanExporter> spanExporterCustomizer) {
Set<String> exporterNames = DefaultConfigProperties.getSet(config, "otel.traces.exporter");
if (exporterNames.contains(EXPORTER_NONE)) {
if (exporterNames.size() > 1) {
throw new ConfigurationException("otel.traces.exporter contains " + EXPORTER_NONE + " along with other exporters");
}
SpanExporter noop = SpanExporter.composite();
SpanExporter customized = spanExporterCustomizer.apply(noop, config);
if (customized == noop) {
return Collections.emptyMap();
}
return Collections.singletonMap(EXPORTER_NONE, customized);
}
if (exporterNames.isEmpty()) {
exporterNames = Collections.singleton("otlp");
}
NamedSpiManager<SpanExporter> spiExportersManager = SpiUtil.loadConfigurable(ConfigurableSpanExporterProvider.class, ConfigurableSpanExporterProvider::getName, ConfigurableSpanExporterProvider::createExporter, config, serviceClassLoader);
return exporterNames.stream().collect(toMap(Function.identity(), exporterName -> spanExporterCustomizer.apply(configureExporter(exporterName, config, spiExportersManager, meterProvider), config)));
}
Aggregations