Search in sources :

Example 1 with ConfigurableSpanExporterProvider

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)));
}
Also used : ConfigProperties(io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties) BiFunction(java.util.function.BiFunction) OtlpHttpSpanExporter(io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporter) Function(java.util.function.Function) PROTOCOL_GRPC(io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.PROTOCOL_GRPC) Collectors.toMap(java.util.stream.Collectors.toMap) PROTOCOL_HTTP_PROTOBUF(io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.PROTOCOL_HTTP_PROTOBUF) Duration(java.time.Duration) Map(java.util.Map) OtlpGrpcSpanExporterBuilder(io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporterBuilder) ZipkinSpanExporter(io.opentelemetry.exporter.zipkin.ZipkinSpanExporter) OtlpGrpcSpanExporter(io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter) DATA_TYPE_TRACES(io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.DATA_TYPE_TRACES) JaegerGrpcSpanExporterBuilder(io.opentelemetry.exporter.jaeger.JaegerGrpcSpanExporterBuilder) ConfigurableSpanExporterProvider(io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider) SpanExporter(io.opentelemetry.sdk.trace.export.SpanExporter) Set(java.util.Set) ConfigurationException(io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException) OtlpHttpSpanExporterBuilder(io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporterBuilder) RetryUtil(io.opentelemetry.exporter.internal.retry.RetryUtil) LoggingSpanExporter(io.opentelemetry.exporter.logging.LoggingSpanExporter) ZipkinSpanExporterBuilder(io.opentelemetry.exporter.zipkin.ZipkinSpanExporterBuilder) JaegerGrpcSpanExporter(io.opentelemetry.exporter.jaeger.JaegerGrpcSpanExporter) MeterProvider(io.opentelemetry.api.metrics.MeterProvider) Collections(java.util.Collections) ConfigurableSpanExporterProvider(io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider) OtlpHttpSpanExporter(io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporter) ZipkinSpanExporter(io.opentelemetry.exporter.zipkin.ZipkinSpanExporter) OtlpGrpcSpanExporter(io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter) SpanExporter(io.opentelemetry.sdk.trace.export.SpanExporter) LoggingSpanExporter(io.opentelemetry.exporter.logging.LoggingSpanExporter) JaegerGrpcSpanExporter(io.opentelemetry.exporter.jaeger.JaegerGrpcSpanExporter) ConfigurationException(io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException)

Aggregations

MeterProvider (io.opentelemetry.api.metrics.MeterProvider)1 RetryUtil (io.opentelemetry.exporter.internal.retry.RetryUtil)1 JaegerGrpcSpanExporter (io.opentelemetry.exporter.jaeger.JaegerGrpcSpanExporter)1 JaegerGrpcSpanExporterBuilder (io.opentelemetry.exporter.jaeger.JaegerGrpcSpanExporterBuilder)1 LoggingSpanExporter (io.opentelemetry.exporter.logging.LoggingSpanExporter)1 OtlpHttpSpanExporter (io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporter)1 OtlpHttpSpanExporterBuilder (io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporterBuilder)1 OtlpGrpcSpanExporter (io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter)1 OtlpGrpcSpanExporterBuilder (io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporterBuilder)1 ZipkinSpanExporter (io.opentelemetry.exporter.zipkin.ZipkinSpanExporter)1 ZipkinSpanExporterBuilder (io.opentelemetry.exporter.zipkin.ZipkinSpanExporterBuilder)1 DATA_TYPE_TRACES (io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.DATA_TYPE_TRACES)1 PROTOCOL_GRPC (io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.PROTOCOL_GRPC)1 PROTOCOL_HTTP_PROTOBUF (io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.PROTOCOL_HTTP_PROTOBUF)1 ConfigProperties (io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties)1 ConfigurationException (io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException)1 ConfigurableSpanExporterProvider (io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider)1 SpanExporter (io.opentelemetry.sdk.trace.export.SpanExporter)1 Duration (java.time.Duration)1 Collections (java.util.Collections)1