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