use of io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporterBuilder 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);
}
}
Aggregations