use of io.opentelemetry.exporter.otlp.http.metrics.OtlpHttpMetricExporterBuilder 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