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);
}
}
Aggregations