Search in sources :

Example 1 with OtlpHttpSpanExporterBuilder

use of io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporterBuilder in project opentelemetry-java by open-telemetry.

the class SpanExporterConfiguration method configureOtlp.

// Visible for testing
static SpanExporter configureOtlp(ConfigProperties config, MeterProvider meterProvider) {
    String protocol = OtlpConfigUtil.getOtlpProtocol(DATA_TYPE_TRACES, config);
    if (protocol.equals(PROTOCOL_HTTP_PROTOBUF)) {
        ClasspathUtil.checkClassExists("io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporter", "OTLP HTTP Trace Exporter", "opentelemetry-exporter-otlp-http-trace");
        OtlpHttpSpanExporterBuilder builder = OtlpHttpSpanExporter.builder();
        OtlpConfigUtil.configureOtlpExporterBuilder(DATA_TYPE_TRACES, config, builder::setEndpoint, builder::addHeader, builder::setCompression, builder::setTimeout, builder::setTrustedCertificates, retryPolicy -> RetryUtil.setRetryPolicyOnDelegate(builder, retryPolicy));
        builder.setMeterProvider(meterProvider);
        return builder.build();
    } else if (protocol.equals(PROTOCOL_GRPC)) {
        ClasspathUtil.checkClassExists("io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter", "OTLP gRPC Trace Exporter", "opentelemetry-exporter-otlp");
        OtlpGrpcSpanExporterBuilder builder = OtlpGrpcSpanExporter.builder();
        OtlpConfigUtil.configureOtlpExporterBuilder(DATA_TYPE_TRACES, config, builder::setEndpoint, builder::addHeader, builder::setCompression, builder::setTimeout, builder::setTrustedCertificates, retryPolicy -> RetryUtil.setRetryPolicyOnDelegate(builder, retryPolicy));
        builder.setMeterProvider(meterProvider);
        return builder.build();
    } else {
        throw new ConfigurationException("Unsupported OTLP traces protocol: " + protocol);
    }
}
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) OtlpGrpcSpanExporterBuilder(io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporterBuilder) ConfigurationException(io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException) OtlpHttpSpanExporterBuilder(io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporterBuilder)

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