Search in sources :

Example 1 with PROTOCOL_HTTP_PROTOBUF

use of io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.PROTOCOL_HTTP_PROTOBUF 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)

Example 2 with PROTOCOL_HTTP_PROTOBUF

use of io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.PROTOCOL_HTTP_PROTOBUF in project opentelemetry-java by open-telemetry.

the class LogExporterConfiguration method configureOtlpLogs.

// Visible for testing
@Nullable
static LogExporter configureOtlpLogs(ConfigProperties config, MeterProvider meterProvider) {
    String protocol = OtlpConfigUtil.getOtlpProtocol(DATA_TYPE_LOGS, config);
    if (protocol.equals(PROTOCOL_HTTP_PROTOBUF)) {
        try {
            ClasspathUtil.checkClassExists("io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogExporter", "OTLP HTTP Log Exporter", "opentelemetry-exporter-otlp-http-logs");
        } catch (ConfigurationException e) {
            // Squash this for now until logs are stable
            return null;
        }
        OtlpHttpLogExporterBuilder builder = OtlpHttpLogExporter.builder();
        OtlpConfigUtil.configureOtlpExporterBuilder(DATA_TYPE_LOGS, 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)) {
        try {
            ClasspathUtil.checkClassExists("io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogExporter", "OTLP gRPC Log Exporter", "opentelemetry-exporter-otlp-logs");
        } catch (ConfigurationException e) {
            // Squash this for now until logs are stable
            return null;
        }
        OtlpGrpcLogExporterBuilder builder = OtlpGrpcLogExporter.builder();
        OtlpConfigUtil.configureOtlpExporterBuilder(DATA_TYPE_LOGS, 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 logs protocol: " + protocol);
    }
}
Also used : ConfigProperties(io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties) LogExporter(io.opentelemetry.sdk.logs.export.LogExporter) OtlpGrpcLogExporter(io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogExporter) OtlpHttpLogExporter(io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogExporter) BiFunction(java.util.function.BiFunction) Set(java.util.Set) SystemOutLogExporter(io.opentelemetry.exporter.logging.SystemOutLogExporter) OtlpHttpLogExporterBuilder(io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogExporterBuilder) HashMap(java.util.HashMap) ConfigurationException(io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException) PROTOCOL_GRPC(io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.PROTOCOL_GRPC) RetryUtil(io.opentelemetry.exporter.internal.retry.RetryUtil) PROTOCOL_HTTP_PROTOBUF(io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.PROTOCOL_HTTP_PROTOBUF) Map(java.util.Map) DATA_TYPE_LOGS(io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.DATA_TYPE_LOGS) MeterProvider(io.opentelemetry.api.metrics.MeterProvider) Collections(java.util.Collections) OtlpGrpcLogExporterBuilder(io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogExporterBuilder) Nullable(javax.annotation.Nullable) OtlpHttpLogExporterBuilder(io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogExporterBuilder) ConfigurationException(io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException) OtlpGrpcLogExporterBuilder(io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogExporterBuilder) Nullable(javax.annotation.Nullable)

Example 3 with PROTOCOL_HTTP_PROTOBUF

use of io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.PROTOCOL_HTTP_PROTOBUF in project opentelemetry-java by open-telemetry.

the class MetricExporterConfiguration method configureOtlpMetrics.

// Visible for testing
@Nullable
static MetricExporter configureOtlpMetrics(ConfigProperties config) {
    String protocol = OtlpConfigUtil.getOtlpProtocol(DATA_TYPE_METRICS, config);
    MetricExporter exporter;
    if (protocol.equals(PROTOCOL_HTTP_PROTOBUF)) {
        try {
            ClasspathUtil.checkClassExists("io.opentelemetry.exporter.otlp.http.metrics.OtlpHttpMetricExporter", "OTLP HTTP Metrics Exporter", "opentelemetry-exporter-otlp-http-metrics");
        } catch (ConfigurationException e) {
            // Squash this for now, until metrics are stable
            return null;
        }
        OtlpHttpMetricExporterBuilder builder = OtlpHttpMetricExporter.builder();
        OtlpConfigUtil.configureOtlpExporterBuilder(DATA_TYPE_METRICS, config, builder::setEndpoint, builder::addHeader, builder::setCompression, builder::setTimeout, builder::setTrustedCertificates, retryPolicy -> RetryUtil.setRetryPolicyOnDelegate(builder, retryPolicy));
        OtlpConfigUtil.configureOtlpAggregationTemporality(config, builder::setPreferredTemporality);
        exporter = builder.build();
    } else if (protocol.equals(PROTOCOL_GRPC)) {
        try {
            ClasspathUtil.checkClassExists("io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporter", "OTLP gRPC Metrics Exporter", "opentelemetry-exporter-otlp-metrics");
        } catch (ConfigurationException e) {
            // by default,
            return null;
        }
        OtlpGrpcMetricExporterBuilder builder = OtlpGrpcMetricExporter.builder();
        OtlpConfigUtil.configureOtlpExporterBuilder(DATA_TYPE_METRICS, config, builder::setEndpoint, builder::addHeader, builder::setCompression, builder::setTimeout, builder::setTrustedCertificates, retryPolicy -> RetryUtil.setRetryPolicyOnDelegate(builder, retryPolicy));
        OtlpConfigUtil.configureOtlpAggregationTemporality(config, builder::setPreferredTemporality);
        exporter = builder.build();
    } else {
        throw new ConfigurationException("Unsupported OTLP metrics protocol: " + protocol);
    }
    return exporter;
}
Also used : LoggingMetricExporter(io.opentelemetry.exporter.logging.LoggingMetricExporter) OtlpHttpMetricExporter(io.opentelemetry.exporter.otlp.http.metrics.OtlpHttpMetricExporter) OtlpGrpcMetricExporter(io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporter) MetricExporter(io.opentelemetry.sdk.metrics.export.MetricExporter) ConfigProperties(io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties) LoggingMetricExporter(io.opentelemetry.exporter.logging.LoggingMetricExporter) ConfigurableMetricExporterProvider(io.opentelemetry.sdk.autoconfigure.spi.metrics.ConfigurableMetricExporterProvider) PrometheusHttpServer(io.opentelemetry.exporter.prometheus.PrometheusHttpServer) DATA_TYPE_METRICS(io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.DATA_TYPE_METRICS) BiFunction(java.util.function.BiFunction) OtlpHttpMetricExporterBuilder(io.opentelemetry.exporter.otlp.http.metrics.OtlpHttpMetricExporterBuilder) ConfigurationException(io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException) PROTOCOL_GRPC(io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.PROTOCOL_GRPC) OtlpHttpMetricExporter(io.opentelemetry.exporter.otlp.http.metrics.OtlpHttpMetricExporter) PrometheusHttpServerBuilder(io.opentelemetry.exporter.prometheus.PrometheusHttpServerBuilder) RetryUtil(io.opentelemetry.exporter.internal.retry.RetryUtil) OtlpGrpcMetricExporter(io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporter) SdkMeterProviderBuilder(io.opentelemetry.sdk.metrics.SdkMeterProviderBuilder) PROTOCOL_HTTP_PROTOBUF(io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.PROTOCOL_HTTP_PROTOBUF) MetricReaderFactory(io.opentelemetry.sdk.metrics.export.MetricReaderFactory) Duration(java.time.Duration) PeriodicMetricReader(io.opentelemetry.sdk.metrics.export.PeriodicMetricReader) OtlpGrpcMetricExporterBuilder(io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporterBuilder) Nullable(javax.annotation.Nullable) MetricExporter(io.opentelemetry.sdk.metrics.export.MetricExporter) OtlpHttpMetricExporterBuilder(io.opentelemetry.exporter.otlp.http.metrics.OtlpHttpMetricExporterBuilder) OtlpGrpcMetricExporterBuilder(io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporterBuilder) ConfigurationException(io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException) Nullable(javax.annotation.Nullable)

Aggregations

RetryUtil (io.opentelemetry.exporter.internal.retry.RetryUtil)3 PROTOCOL_GRPC (io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.PROTOCOL_GRPC)3 PROTOCOL_HTTP_PROTOBUF (io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.PROTOCOL_HTTP_PROTOBUF)3 ConfigProperties (io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties)3 ConfigurationException (io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException)3 BiFunction (java.util.function.BiFunction)3 MeterProvider (io.opentelemetry.api.metrics.MeterProvider)2 Duration (java.time.Duration)2 Collections (java.util.Collections)2 Map (java.util.Map)2 Set (java.util.Set)2 Nullable (javax.annotation.Nullable)2 JaegerGrpcSpanExporter (io.opentelemetry.exporter.jaeger.JaegerGrpcSpanExporter)1 JaegerGrpcSpanExporterBuilder (io.opentelemetry.exporter.jaeger.JaegerGrpcSpanExporterBuilder)1 LoggingMetricExporter (io.opentelemetry.exporter.logging.LoggingMetricExporter)1 LoggingSpanExporter (io.opentelemetry.exporter.logging.LoggingSpanExporter)1 SystemOutLogExporter (io.opentelemetry.exporter.logging.SystemOutLogExporter)1 OtlpHttpLogExporter (io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogExporter)1 OtlpHttpLogExporterBuilder (io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogExporterBuilder)1 OtlpHttpMetricExporter (io.opentelemetry.exporter.otlp.http.metrics.OtlpHttpMetricExporter)1