Search in sources :

Example 1 with OtlpHttpLogExporterBuilder

use of io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogExporterBuilder 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)

Aggregations

MeterProvider (io.opentelemetry.api.metrics.MeterProvider)1 RetryUtil (io.opentelemetry.exporter.internal.retry.RetryUtil)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 OtlpGrpcLogExporter (io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogExporter)1 OtlpGrpcLogExporterBuilder (io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogExporterBuilder)1 DATA_TYPE_LOGS (io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.DATA_TYPE_LOGS)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 LogExporter (io.opentelemetry.sdk.logs.export.LogExporter)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Set (java.util.Set)1 BiFunction (java.util.function.BiFunction)1 Nullable (javax.annotation.Nullable)1