From 5b497b115d567c725cb74dc1543f5e02e41b3fbf Mon Sep 17 00:00:00 2001
From: jack-berg <34418638+jack-berg@users.noreply.github.com>
Date: Sun, 18 Dec 2022 07:57:55 -0600
Subject: [PATCH] Implement otlp exporter providers (#5003)
* Implement otlp exporter providers
* Remove redundant else
* Restore unsupported protocol test
---
exporters/otlp/all/build.gradle.kts | 1 +
.../internal/OtlpMetricExporterProvider.java | 81 +++++++++++
.../internal/OtlpSpanExporterProvider.java | 72 ++++++++++
...metrics.ConfigurableMetricExporterProvider | 1 +
...pi.traces.ConfigurableSpanExporterProvider | 1 +
exporters/otlp/common/build.gradle.kts | 2 +
.../internal/otlp}/OtlpConfigUtil.java | 54 ++++---
.../internal/otlp}/OtlpConfigUtilTest.java | 14 +-
exporters/otlp/logs/build.gradle.kts | 1 +
.../OtlpLogRecordExporterProvider.java | 73 ++++++++++
...logs.ConfigurableLogRecordExporterProvider | 1 +
sdk-extensions/autoconfigure/build.gradle.kts | 11 +-
.../LogRecordExporterConfiguration.java | 120 +++-------------
.../LoggerProviderConfiguration.java | 3 +-
.../MeterProviderConfiguration.java | 2 +-
.../MetricExporterConfiguration.java | 126 ++++------------
.../SpanExporterConfiguration.java | 100 +++----------
.../TracerProviderConfiguration.java | 2 +-
.../LogRecordExporterConfigurationTest.java | 16 ---
.../sdk/autoconfigure/NotOnClasspathTest.java | 135 +++++-------------
.../ConfigurableLogRecordExporterTest.java | 17 +--
.../ConfigurableMetricExporterTest.java | 26 ++--
.../ConfigurableSpanExporterTest.java | 25 +---
.../LogRecordExporterConfigurationTest.java | 30 ++++
.../MetricExporterConfigurationTest.java | 9 +-
.../SpanExporterConfigurationTest.java | 29 ++--
.../sdk/autoconfigure/OtlpGrpcConfigTest.java | 83 ++++++++---
.../sdk/autoconfigure/OtlpGrpcRetryTest.java | 22 +--
.../sdk/autoconfigure/OtlpHttpConfigTest.java | 84 ++++++++---
.../sdk/autoconfigure/OtlpHttpRetryTest.java | 22 +--
30 files changed, 607 insertions(+), 556 deletions(-)
create mode 100644 exporters/otlp/all/src/main/java/io/opentelemetry/exporter/otlp/internal/OtlpMetricExporterProvider.java
create mode 100644 exporters/otlp/all/src/main/java/io/opentelemetry/exporter/otlp/internal/OtlpSpanExporterProvider.java
create mode 100644 exporters/otlp/all/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.metrics.ConfigurableMetricExporterProvider
create mode 100644 exporters/otlp/all/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider
rename {sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure => exporters/otlp/common/src/main/java/io/opentelemetry/exporter/internal/otlp}/OtlpConfigUtil.java (85%)
rename {sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure => exporters/otlp/common/src/test/java/io/opentelemetry/exporter/internal/otlp}/OtlpConfigUtilTest.java (96%)
create mode 100644 exporters/otlp/logs/src/main/java/io/opentelemetry/exporter/otlp/internal/OtlpLogRecordExporterProvider.java
create mode 100644 exporters/otlp/logs/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.logs.ConfigurableLogRecordExporterProvider
create mode 100644 sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/LogRecordExporterConfigurationTest.java
diff --git a/exporters/otlp/all/build.gradle.kts b/exporters/otlp/all/build.gradle.kts
index 35fb7695015..e3529c57ca9 100644
--- a/exporters/otlp/all/build.gradle.kts
+++ b/exporters/otlp/all/build.gradle.kts
@@ -15,6 +15,7 @@ dependencies {
api(project(":sdk:metrics"))
implementation(project(":exporters:otlp:common"))
+ implementation(project(":sdk-extensions:autoconfigure-spi"))
compileOnly("io.grpc:grpc-stub")
diff --git a/exporters/otlp/all/src/main/java/io/opentelemetry/exporter/otlp/internal/OtlpMetricExporterProvider.java b/exporters/otlp/all/src/main/java/io/opentelemetry/exporter/otlp/internal/OtlpMetricExporterProvider.java
new file mode 100644
index 00000000000..daa54293903
--- /dev/null
+++ b/exporters/otlp/all/src/main/java/io/opentelemetry/exporter/otlp/internal/OtlpMetricExporterProvider.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package io.opentelemetry.exporter.otlp.internal;
+
+import static io.opentelemetry.exporter.internal.otlp.OtlpConfigUtil.DATA_TYPE_METRICS;
+import static io.opentelemetry.exporter.internal.otlp.OtlpConfigUtil.PROTOCOL_GRPC;
+import static io.opentelemetry.exporter.internal.otlp.OtlpConfigUtil.PROTOCOL_HTTP_PROTOBUF;
+
+import io.opentelemetry.exporter.internal.otlp.OtlpConfigUtil;
+import io.opentelemetry.exporter.internal.retry.RetryUtil;
+import io.opentelemetry.exporter.otlp.http.metrics.OtlpHttpMetricExporter;
+import io.opentelemetry.exporter.otlp.http.metrics.OtlpHttpMetricExporterBuilder;
+import io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporter;
+import io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporterBuilder;
+import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
+import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
+import io.opentelemetry.sdk.autoconfigure.spi.metrics.ConfigurableMetricExporterProvider;
+import io.opentelemetry.sdk.metrics.export.MetricExporter;
+
+/**
+ * {@link MetricExporter} SPI implementation for {@link OtlpGrpcMetricExporter} and {@link
+ * OtlpHttpMetricExporter}.
+ *
+ *
This class is internal and is hence not for public use. Its APIs are unstable and can change
+ * at any time.
+ */
+public class OtlpMetricExporterProvider implements ConfigurableMetricExporterProvider {
+ @Override
+ public MetricExporter createExporter(ConfigProperties config) {
+ String protocol = OtlpConfigUtil.getOtlpProtocol(DATA_TYPE_METRICS, config);
+
+ if (protocol.equals(PROTOCOL_HTTP_PROTOBUF)) {
+ OtlpHttpMetricExporterBuilder builder = OtlpHttpMetricExporter.builder();
+
+ OtlpConfigUtil.configureOtlpExporterBuilder(
+ DATA_TYPE_METRICS,
+ config,
+ builder::setEndpoint,
+ builder::addHeader,
+ builder::setCompression,
+ builder::setTimeout,
+ builder::setTrustedCertificates,
+ builder::setClientTls,
+ retryPolicy -> RetryUtil.setRetryPolicyOnDelegate(builder, retryPolicy));
+ OtlpConfigUtil.configureOtlpAggregationTemporality(
+ config, builder::setAggregationTemporalitySelector);
+ OtlpConfigUtil.configureOtlpHistogramDefaultAggregation(
+ config, builder::setDefaultAggregationSelector);
+
+ return builder.build();
+ } else if (protocol.equals(PROTOCOL_GRPC)) {
+ OtlpGrpcMetricExporterBuilder builder = OtlpGrpcMetricExporter.builder();
+
+ OtlpConfigUtil.configureOtlpExporterBuilder(
+ DATA_TYPE_METRICS,
+ config,
+ builder::setEndpoint,
+ builder::addHeader,
+ builder::setCompression,
+ builder::setTimeout,
+ builder::setTrustedCertificates,
+ builder::setClientTls,
+ retryPolicy -> RetryUtil.setRetryPolicyOnDelegate(builder, retryPolicy));
+ OtlpConfigUtil.configureOtlpAggregationTemporality(
+ config, builder::setAggregationTemporalitySelector);
+ OtlpConfigUtil.configureOtlpHistogramDefaultAggregation(
+ config, builder::setDefaultAggregationSelector);
+
+ return builder.build();
+ }
+ throw new ConfigurationException("Unsupported OTLP metrics protocol: " + protocol);
+ }
+
+ @Override
+ public String getName() {
+ return "otlp";
+ }
+}
diff --git a/exporters/otlp/all/src/main/java/io/opentelemetry/exporter/otlp/internal/OtlpSpanExporterProvider.java b/exporters/otlp/all/src/main/java/io/opentelemetry/exporter/otlp/internal/OtlpSpanExporterProvider.java
new file mode 100644
index 00000000000..084998f4f8a
--- /dev/null
+++ b/exporters/otlp/all/src/main/java/io/opentelemetry/exporter/otlp/internal/OtlpSpanExporterProvider.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package io.opentelemetry.exporter.otlp.internal;
+
+import static io.opentelemetry.exporter.internal.otlp.OtlpConfigUtil.DATA_TYPE_TRACES;
+import static io.opentelemetry.exporter.internal.otlp.OtlpConfigUtil.PROTOCOL_GRPC;
+import static io.opentelemetry.exporter.internal.otlp.OtlpConfigUtil.PROTOCOL_HTTP_PROTOBUF;
+
+import io.opentelemetry.exporter.internal.otlp.OtlpConfigUtil;
+import io.opentelemetry.exporter.internal.retry.RetryUtil;
+import io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporter;
+import io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporterBuilder;
+import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter;
+import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporterBuilder;
+import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
+import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
+import io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider;
+import io.opentelemetry.sdk.trace.export.SpanExporter;
+
+/**
+ * {@link SpanExporter} SPI implementation for {@link OtlpGrpcSpanExporter} and {@link
+ * OtlpHttpSpanExporter}.
+ *
+ *
This class is internal and is hence not for public use. Its APIs are unstable and can change
+ * at any time.
+ */
+public class OtlpSpanExporterProvider implements ConfigurableSpanExporterProvider {
+ @Override
+ public SpanExporter createExporter(ConfigProperties config) {
+ String protocol = OtlpConfigUtil.getOtlpProtocol(DATA_TYPE_TRACES, config);
+ if (protocol.equals(PROTOCOL_HTTP_PROTOBUF)) {
+ OtlpHttpSpanExporterBuilder builder = OtlpHttpSpanExporter.builder();
+
+ OtlpConfigUtil.configureOtlpExporterBuilder(
+ DATA_TYPE_TRACES,
+ config,
+ builder::setEndpoint,
+ builder::addHeader,
+ builder::setCompression,
+ builder::setTimeout,
+ builder::setTrustedCertificates,
+ builder::setClientTls,
+ retryPolicy -> RetryUtil.setRetryPolicyOnDelegate(builder, retryPolicy));
+
+ return builder.build();
+ } else if (protocol.equals(PROTOCOL_GRPC)) {
+ OtlpGrpcSpanExporterBuilder builder = OtlpGrpcSpanExporter.builder();
+
+ OtlpConfigUtil.configureOtlpExporterBuilder(
+ DATA_TYPE_TRACES,
+ config,
+ builder::setEndpoint,
+ builder::addHeader,
+ builder::setCompression,
+ builder::setTimeout,
+ builder::setTrustedCertificates,
+ builder::setClientTls,
+ retryPolicy -> RetryUtil.setRetryPolicyOnDelegate(builder, retryPolicy));
+
+ return builder.build();
+ }
+ throw new ConfigurationException("Unsupported OTLP traces protocol: " + protocol);
+ }
+
+ @Override
+ public String getName() {
+ return "otlp";
+ }
+}
diff --git a/exporters/otlp/all/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.metrics.ConfigurableMetricExporterProvider b/exporters/otlp/all/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.metrics.ConfigurableMetricExporterProvider
new file mode 100644
index 00000000000..93d8d0ee99a
--- /dev/null
+++ b/exporters/otlp/all/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.metrics.ConfigurableMetricExporterProvider
@@ -0,0 +1 @@
+io.opentelemetry.exporter.otlp.internal.OtlpMetricExporterProvider
diff --git a/exporters/otlp/all/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider b/exporters/otlp/all/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider
new file mode 100644
index 00000000000..29112b59867
--- /dev/null
+++ b/exporters/otlp/all/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider
@@ -0,0 +1 @@
+io.opentelemetry.exporter.otlp.internal.OtlpSpanExporterProvider
diff --git a/exporters/otlp/common/build.gradle.kts b/exporters/otlp/common/build.gradle.kts
index d85d2688789..9d7a7c7ce4b 100644
--- a/exporters/otlp/common/build.gradle.kts
+++ b/exporters/otlp/common/build.gradle.kts
@@ -17,6 +17,8 @@ dependencies {
api(project(":exporters:common"))
+ implementation(project(":sdk-extensions:autoconfigure-spi"))
+
compileOnly(project(":sdk:metrics"))
compileOnly(project(":sdk:trace"))
compileOnly(project(":sdk:logs"))
diff --git a/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/OtlpConfigUtil.java b/exporters/otlp/common/src/main/java/io/opentelemetry/exporter/internal/otlp/OtlpConfigUtil.java
similarity index 85%
rename from sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/OtlpConfigUtil.java
rename to exporters/otlp/common/src/main/java/io/opentelemetry/exporter/internal/otlp/OtlpConfigUtil.java
index 6fd8e1d7fb7..979bc57d825 100644
--- a/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/OtlpConfigUtil.java
+++ b/exporters/otlp/common/src/main/java/io/opentelemetry/exporter/internal/otlp/OtlpConfigUtil.java
@@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
-package io.opentelemetry.sdk.autoconfigure;
+package io.opentelemetry.exporter.internal.otlp;
import io.opentelemetry.exporter.internal.retry.RetryPolicy;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
@@ -13,28 +13,32 @@
import io.opentelemetry.sdk.metrics.export.AggregationTemporalitySelector;
import io.opentelemetry.sdk.metrics.export.DefaultAggregationSelector;
import io.opentelemetry.sdk.metrics.internal.view.ExponentialHistogramAggregation;
+import java.io.File;
import java.io.IOException;
+import java.io.RandomAccessFile;
import java.net.MalformedURLException;
import java.net.URL;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
import java.time.Duration;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import javax.annotation.Nullable;
-final class OtlpConfigUtil {
+/**
+ * This class is internal and is hence not for public use. Its APIs are unstable and can change at
+ * any time.
+ */
+public final class OtlpConfigUtil {
- static final String DATA_TYPE_TRACES = "traces";
- static final String DATA_TYPE_METRICS = "metrics";
- static final String DATA_TYPE_LOGS = "logs";
+ public static final String DATA_TYPE_TRACES = "traces";
+ public static final String DATA_TYPE_METRICS = "metrics";
+ public static final String DATA_TYPE_LOGS = "logs";
- static final String PROTOCOL_GRPC = "grpc";
- static final String PROTOCOL_HTTP_PROTOBUF = "http/protobuf";
+ public static final String PROTOCOL_GRPC = "grpc";
+ public static final String PROTOCOL_HTTP_PROTOBUF = "http/protobuf";
- static String getOtlpProtocol(String dataType, ConfigProperties config) {
+ /** Determine the configured OTLP protocol for the {@code dataType}. */
+ public static String getOtlpProtocol(String dataType, ConfigProperties config) {
String protocol = config.getString("otel.exporter.otlp." + dataType + ".protocol");
if (protocol != null) {
return protocol;
@@ -42,7 +46,8 @@ static String getOtlpProtocol(String dataType, ConfigProperties config) {
return config.getString("otel.exporter.otlp.protocol", PROTOCOL_GRPC);
}
- static void configureOtlpExporterBuilder(
+ /** Invoke the setters with the OTLP configuration for the {@code dataType}. */
+ public static void configureOtlpExporterBuilder(
String dataType,
ConfigProperties config,
Consumer setEndpoint,
@@ -133,7 +138,11 @@ static void configureOtlpExporterBuilder(
}
}
- static void configureOtlpAggregationTemporality(
+ /**
+ * Invoke the {@code aggregationTemporalitySelectorConsumer} with the configured {@link
+ * AggregationTemporality}.
+ */
+ public static void configureOtlpAggregationTemporality(
ConfigProperties config,
Consumer aggregationTemporalitySelectorConsumer) {
String temporalityStr = config.getString("otel.exporter.otlp.metrics.temporality.preference");
@@ -154,7 +163,11 @@ static void configureOtlpAggregationTemporality(
aggregationTemporalitySelectorConsumer.accept(temporalitySelector);
}
- static void configureOtlpHistogramDefaultAggregation(
+ /**
+ * Invoke the {@code defaultAggregationSelectorConsumer} with the configured {@link
+ * DefaultAggregationSelector}.
+ */
+ public static void configureOtlpHistogramDefaultAggregation(
ConfigProperties config,
Consumer defaultAggregationSelectorConsumer) {
String defaultHistogramAggregation =
@@ -215,14 +228,17 @@ private static byte[] readFileBytes(@Nullable String filePath) {
if (filePath == null) {
return null;
}
- Path path = Paths.get(filePath);
- if (!Files.exists(path)) {
- throw new ConfigurationException("Invalid OTLP certificate/key path: " + path);
+ File file = new File(filePath);
+ if (!file.exists()) {
+ throw new ConfigurationException("Invalid OTLP certificate/key path: " + filePath);
}
try {
- return Files.readAllBytes(path);
+ RandomAccessFile raf = new RandomAccessFile(file, "r");
+ byte[] bytes = new byte[(int) raf.length()];
+ raf.readFully(bytes);
+ return bytes;
} catch (IOException e) {
- throw new ConfigurationException("Error reading content of file (" + path + ")", e);
+ throw new ConfigurationException("Error reading content of file (" + filePath + ")", e);
}
}
diff --git a/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/OtlpConfigUtilTest.java b/exporters/otlp/common/src/test/java/io/opentelemetry/exporter/internal/otlp/OtlpConfigUtilTest.java
similarity index 96%
rename from sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/OtlpConfigUtilTest.java
rename to exporters/otlp/common/src/test/java/io/opentelemetry/exporter/internal/otlp/OtlpConfigUtilTest.java
index de795f50e08..b4f93f7a87b 100644
--- a/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/OtlpConfigUtilTest.java
+++ b/exporters/otlp/common/src/test/java/io/opentelemetry/exporter/internal/otlp/OtlpConfigUtilTest.java
@@ -3,14 +3,14 @@
* SPDX-License-Identifier: Apache-2.0
*/
-package io.opentelemetry.sdk.autoconfigure;
+package io.opentelemetry.exporter.internal.otlp;
-import static io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.DATA_TYPE_LOGS;
-import static io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.DATA_TYPE_METRICS;
-import static io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.DATA_TYPE_TRACES;
-import static io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.PROTOCOL_GRPC;
-import static io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.PROTOCOL_HTTP_PROTOBUF;
-import static org.assertj.core.api.Assertions.assertThat;
+import static io.opentelemetry.exporter.internal.otlp.OtlpConfigUtil.DATA_TYPE_LOGS;
+import static io.opentelemetry.exporter.internal.otlp.OtlpConfigUtil.DATA_TYPE_METRICS;
+import static io.opentelemetry.exporter.internal.otlp.OtlpConfigUtil.DATA_TYPE_TRACES;
+import static io.opentelemetry.exporter.internal.otlp.OtlpConfigUtil.PROTOCOL_GRPC;
+import static io.opentelemetry.exporter.internal.otlp.OtlpConfigUtil.PROTOCOL_HTTP_PROTOBUF;
+import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
diff --git a/exporters/otlp/logs/build.gradle.kts b/exporters/otlp/logs/build.gradle.kts
index 000b8e5da3e..2f33efe34d7 100644
--- a/exporters/otlp/logs/build.gradle.kts
+++ b/exporters/otlp/logs/build.gradle.kts
@@ -12,6 +12,7 @@ dependencies {
api(project(":sdk:logs"))
implementation(project(":exporters:otlp:common"))
+ implementation(project(":sdk-extensions:autoconfigure-spi"))
compileOnly("io.grpc:grpc-stub")
diff --git a/exporters/otlp/logs/src/main/java/io/opentelemetry/exporter/otlp/internal/OtlpLogRecordExporterProvider.java b/exporters/otlp/logs/src/main/java/io/opentelemetry/exporter/otlp/internal/OtlpLogRecordExporterProvider.java
new file mode 100644
index 00000000000..d212b80e5d3
--- /dev/null
+++ b/exporters/otlp/logs/src/main/java/io/opentelemetry/exporter/otlp/internal/OtlpLogRecordExporterProvider.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package io.opentelemetry.exporter.otlp.internal;
+
+import static io.opentelemetry.exporter.internal.otlp.OtlpConfigUtil.DATA_TYPE_LOGS;
+import static io.opentelemetry.exporter.internal.otlp.OtlpConfigUtil.PROTOCOL_GRPC;
+import static io.opentelemetry.exporter.internal.otlp.OtlpConfigUtil.PROTOCOL_HTTP_PROTOBUF;
+
+import io.opentelemetry.exporter.internal.otlp.OtlpConfigUtil;
+import io.opentelemetry.exporter.internal.retry.RetryUtil;
+import io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogRecordExporter;
+import io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogRecordExporterBuilder;
+import io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporter;
+import io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporterBuilder;
+import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
+import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
+import io.opentelemetry.sdk.autoconfigure.spi.logs.ConfigurableLogRecordExporterProvider;
+import io.opentelemetry.sdk.logs.export.LogRecordExporter;
+
+/**
+ * {@link LogRecordExporter} SPI implementation for {@link OtlpGrpcLogRecordExporter} and {@link
+ * OtlpHttpLogRecordExporter}.
+ *
+ * This class is internal and is hence not for public use. Its APIs are unstable and can change
+ * at any time.
+ */
+public class OtlpLogRecordExporterProvider implements ConfigurableLogRecordExporterProvider {
+ @Override
+ public LogRecordExporter createExporter(ConfigProperties config) {
+ String protocol = OtlpConfigUtil.getOtlpProtocol(DATA_TYPE_LOGS, config);
+
+ if (protocol.equals(PROTOCOL_HTTP_PROTOBUF)) {
+ OtlpHttpLogRecordExporterBuilder builder = OtlpHttpLogRecordExporter.builder();
+
+ OtlpConfigUtil.configureOtlpExporterBuilder(
+ DATA_TYPE_LOGS,
+ config,
+ builder::setEndpoint,
+ builder::addHeader,
+ builder::setCompression,
+ builder::setTimeout,
+ builder::setTrustedCertificates,
+ builder::setClientTls,
+ retryPolicy -> RetryUtil.setRetryPolicyOnDelegate(builder, retryPolicy));
+
+ return builder.build();
+ } else if (protocol.equals(PROTOCOL_GRPC)) {
+ OtlpGrpcLogRecordExporterBuilder builder = OtlpGrpcLogRecordExporter.builder();
+
+ OtlpConfigUtil.configureOtlpExporterBuilder(
+ DATA_TYPE_LOGS,
+ config,
+ builder::setEndpoint,
+ builder::addHeader,
+ builder::setCompression,
+ builder::setTimeout,
+ builder::setTrustedCertificates,
+ builder::setClientTls,
+ retryPolicy -> RetryUtil.setRetryPolicyOnDelegate(builder, retryPolicy));
+
+ return builder.build();
+ }
+ throw new ConfigurationException("Unsupported OTLP logs protocol: " + protocol);
+ }
+
+ @Override
+ public String getName() {
+ return "otlp";
+ }
+}
diff --git a/exporters/otlp/logs/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.logs.ConfigurableLogRecordExporterProvider b/exporters/otlp/logs/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.logs.ConfigurableLogRecordExporterProvider
new file mode 100644
index 00000000000..d789ed482c7
--- /dev/null
+++ b/exporters/otlp/logs/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.logs.ConfigurableLogRecordExporterProvider
@@ -0,0 +1 @@
+io.opentelemetry.exporter.otlp.internal.OtlpLogRecordExporterProvider
diff --git a/sdk-extensions/autoconfigure/build.gradle.kts b/sdk-extensions/autoconfigure/build.gradle.kts
index 1deef8e036f..3b8e983ff0e 100644
--- a/sdk-extensions/autoconfigure/build.gradle.kts
+++ b/sdk-extensions/autoconfigure/build.gradle.kts
@@ -13,23 +13,16 @@ dependencies {
api(project(":sdk-extensions:autoconfigure-spi"))
implementation(project(":semconv"))
- implementation(project(":exporters:common"))
- compileOnly(project(":exporters:otlp:all"))
- compileOnly(project(":exporters:otlp:logs"))
- compileOnly(project(":exporters:otlp:common"))
compileOnly(project(":exporters:prometheus"))
annotationProcessor("com.google.auto.value:auto-value")
testImplementation(project(":sdk:trace-shaded-deps"))
-
testImplementation(project(":sdk:testing"))
- testImplementation("com.linecorp.armeria:armeria-junit5")
- testImplementation("com.linecorp.armeria:armeria-grpc")
+
+ testImplementation("com.google.guava:guava")
testImplementation("edu.berkeley.cs.jqf:jqf-fuzz")
- testRuntimeOnly("io.grpc:grpc-netty-shaded")
- testImplementation("io.opentelemetry.proto:opentelemetry-proto")
}
testing {
diff --git a/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/LogRecordExporterConfiguration.java b/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/LogRecordExporterConfiguration.java
index 0d7a38b3097..f00a56bbb2e 100644
--- a/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/LogRecordExporterConfiguration.java
+++ b/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/LogRecordExporterConfiguration.java
@@ -5,16 +5,6 @@
package io.opentelemetry.sdk.autoconfigure;
-import static io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.DATA_TYPE_LOGS;
-import static io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.PROTOCOL_GRPC;
-import static io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.PROTOCOL_HTTP_PROTOBUF;
-
-import io.opentelemetry.api.metrics.MeterProvider;
-import io.opentelemetry.exporter.internal.retry.RetryUtil;
-import io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogRecordExporter;
-import io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogRecordExporterBuilder;
-import io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporter;
-import io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporterBuilder;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
@@ -25,7 +15,6 @@
import java.util.Map;
import java.util.Set;
import java.util.function.BiFunction;
-import javax.annotation.Nullable;
class LogRecordExporterConfiguration {
@@ -36,13 +25,13 @@ class LogRecordExporterConfiguration {
EXPORTER_ARTIFACT_ID_BY_NAME = new HashMap<>();
EXPORTER_ARTIFACT_ID_BY_NAME.put("logging", "opentelemetry-exporter-logging");
EXPORTER_ARTIFACT_ID_BY_NAME.put("logging-otlp", "opentelemetry-exporter-logging-otlp");
+ EXPORTER_ARTIFACT_ID_BY_NAME.put("otlp", "opentelemetry-exporter-otlp");
}
// Visible for test
static Map configureLogRecordExporters(
ConfigProperties config,
ClassLoader serviceClassLoader,
- MeterProvider meterProvider,
BiFunction super LogRecordExporter, ConfigProperties, ? extends LogRecordExporter>
logRecordExporterCustomizer) {
Set exporterNames = DefaultConfigProperties.getSet(config, "otel.logs.exporter");
@@ -65,13 +54,10 @@ static Map configureLogRecordExporters(
Map exportersByName = new HashMap<>();
for (String name : exporterNames) {
- LogRecordExporter logRecordExporter =
- configureExporter(name, config, spiExportersManager, meterProvider);
- if (logRecordExporter != null) {
- LogRecordExporter customizedLogRecordExporter =
- logRecordExporterCustomizer.apply(logRecordExporter, config);
- exportersByName.put(name, customizedLogRecordExporter);
- }
+ LogRecordExporter logRecordExporter = configureExporter(name, spiExportersManager);
+ LogRecordExporter customizedLogRecordExporter =
+ logRecordExporterCustomizer.apply(logRecordExporter, config);
+ exportersByName.put(name, customizedLogRecordExporter);
}
return Collections.unmodifiableMap(exportersByName);
@@ -89,92 +75,22 @@ static NamedSpiManager logRecordExporterSpiManager(
}
// Visible for testing
- @Nullable
static LogRecordExporter configureExporter(
- String name,
- ConfigProperties config,
- NamedSpiManager spiExportersManager,
- MeterProvider meterProvider) {
- switch (name) {
- case "otlp":
- return configureOtlpLogs(config, meterProvider);
- default:
- LogRecordExporter spiExporter = spiExportersManager.getByName(name);
- if (spiExporter == null) {
- String artifactId = EXPORTER_ARTIFACT_ID_BY_NAME.get(name);
- if (artifactId != null) {
- throw new ConfigurationException(
- "otel.logs.exporter set to \""
- + name
- + "\" but "
- + artifactId
- + " not found on classpath. Make sure to add it as a dependency.");
- }
- throw new ConfigurationException("Unrecognized value for otel.logs.exporter: " + name);
- }
- return spiExporter;
- }
- }
-
- // Visible for testing
- @Nullable
- static LogRecordExporter 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.OtlpHttpLogRecordExporter",
- "OTLP HTTP Log Exporter",
- "opentelemetry-exporter-otlp-http-logs");
- } catch (ConfigurationException e) {
- // Squash this for now until logs are stable
- return null;
- }
- OtlpHttpLogRecordExporterBuilder builder = OtlpHttpLogRecordExporter.builder();
-
- OtlpConfigUtil.configureOtlpExporterBuilder(
- DATA_TYPE_LOGS,
- config,
- builder::setEndpoint,
- builder::addHeader,
- builder::setCompression,
- builder::setTimeout,
- builder::setTrustedCertificates,
- builder::setClientTls,
- 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.OtlpGrpcLogRecordExporter",
- "OTLP gRPC Log Exporter",
- "opentelemetry-exporter-otlp-logs");
- } catch (ConfigurationException e) {
- // Squash this for now until logs are stable
- return null;
+ String name, NamedSpiManager spiExportersManager) {
+ LogRecordExporter spiExporter = spiExportersManager.getByName(name);
+ if (spiExporter == null) {
+ String artifactId = EXPORTER_ARTIFACT_ID_BY_NAME.get(name);
+ if (artifactId != null) {
+ throw new ConfigurationException(
+ "otel.logs.exporter set to \""
+ + name
+ + "\" but "
+ + artifactId
+ + " not found on classpath. Make sure to add it as a dependency.");
}
- OtlpGrpcLogRecordExporterBuilder builder = OtlpGrpcLogRecordExporter.builder();
-
- OtlpConfigUtil.configureOtlpExporterBuilder(
- DATA_TYPE_LOGS,
- config,
- builder::setEndpoint,
- builder::addHeader,
- builder::setCompression,
- builder::setTimeout,
- builder::setTrustedCertificates,
- builder::setClientTls,
- retryPolicy -> RetryUtil.setRetryPolicyOnDelegate(builder, retryPolicy));
- builder.setMeterProvider(meterProvider);
-
- return builder.build();
- } else {
- throw new ConfigurationException("Unsupported OTLP logs protocol: " + protocol);
+ throw new ConfigurationException("Unrecognized value for otel.logs.exporter: " + name);
}
+ return spiExporter;
}
private LogRecordExporterConfiguration() {}
diff --git a/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/LoggerProviderConfiguration.java b/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/LoggerProviderConfiguration.java
index 1ebddd5b0e0..1f31f70defa 100644
--- a/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/LoggerProviderConfiguration.java
+++ b/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/LoggerProviderConfiguration.java
@@ -37,8 +37,7 @@ static void configureLoggerProvider(
loggerProviderBuilder.setLogLimits(() -> configureLogLimits(config));
Map exportersByName =
- configureLogRecordExporters(
- config, serviceClassLoader, meterProvider, logRecordExporterCustomizer);
+ configureLogRecordExporters(config, serviceClassLoader, logRecordExporterCustomizer);
configureLogRecordProcessors(config, exportersByName, meterProvider)
.forEach(loggerProviderBuilder::addLogRecordProcessor);
diff --git a/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/MeterProviderConfiguration.java b/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/MeterProviderConfiguration.java
index 40dd14c0a7c..fac7c3ac2bf 100644
--- a/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/MeterProviderConfiguration.java
+++ b/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/MeterProviderConfiguration.java
@@ -68,7 +68,7 @@ static List configureMetricReaders(
return exporterNames.stream()
.map(
exporterName ->
- MetricExporterConfiguration.configureExporter(
+ MetricExporterConfiguration.configureReader(
exporterName, config, serviceClassLoader, metricExporterCustomizer))
.collect(Collectors.toList());
}
diff --git a/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/MetricExporterConfiguration.java b/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/MetricExporterConfiguration.java
index 11d9d45061d..eec05b99efd 100644
--- a/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/MetricExporterConfiguration.java
+++ b/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/MetricExporterConfiguration.java
@@ -5,15 +5,6 @@
package io.opentelemetry.sdk.autoconfigure;
-import static io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.DATA_TYPE_METRICS;
-import static io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.PROTOCOL_GRPC;
-import static io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.PROTOCOL_HTTP_PROTOBUF;
-
-import io.opentelemetry.exporter.internal.retry.RetryUtil;
-import io.opentelemetry.exporter.otlp.http.metrics.OtlpHttpMetricExporter;
-import io.opentelemetry.exporter.otlp.http.metrics.OtlpHttpMetricExporterBuilder;
-import io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporter;
-import io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporterBuilder;
import io.opentelemetry.exporter.prometheus.PrometheusHttpServer;
import io.opentelemetry.exporter.prometheus.PrometheusHttpServerBuilder;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
@@ -26,7 +17,6 @@
import java.util.HashMap;
import java.util.Map;
import java.util.function.BiFunction;
-import javax.annotation.Nullable;
final class MetricExporterConfiguration {
@@ -37,9 +27,10 @@ final class MetricExporterConfiguration {
EXPORTER_ARTIFACT_ID_BY_NAME = new HashMap<>();
EXPORTER_ARTIFACT_ID_BY_NAME.put("logging", "opentelemetry-exporter-logging");
EXPORTER_ARTIFACT_ID_BY_NAME.put("logging-otlp", "opentelemetry-exporter-logging-otlp");
+ EXPORTER_ARTIFACT_ID_BY_NAME.put("otlp", "opentelemetry-exporter-otlp");
}
- static MetricReader configureExporter(
+ static MetricReader configureReader(
String name,
ConfigProperties config,
ClassLoader serviceClassLoader,
@@ -49,99 +40,42 @@ static MetricReader configureExporter(
return configurePrometheusMetricReader(config);
}
- MetricExporter metricExporter;
- switch (name) {
- case "otlp":
- metricExporter = configureOtlpMetrics(config);
- break;
- default:
- MetricExporter spiExporter = configureSpiExporter(name, config, serviceClassLoader);
- if (spiExporter == null) {
- String artifactId = EXPORTER_ARTIFACT_ID_BY_NAME.get(name);
- if (artifactId != null) {
- throw new ConfigurationException(
- "otel.metrics.exporter set to \""
- + name
- + "\" but "
- + artifactId
- + " not found on classpath. Make sure to add it as a dependency.");
- }
- throw new ConfigurationException("Unrecognized value for otel.metrics.exporter: " + name);
- }
- metricExporter = spiExporter;
- }
+ NamedSpiManager spiExportersManager =
+ metricExporterSpiManager(config, serviceClassLoader);
+ MetricExporter metricExporter = configureExporter(name, spiExportersManager);
metricExporter = metricExporterCustomizer.apply(metricExporter, config);
return configurePeriodicMetricReader(config, metricExporter);
}
- // Visible for testing.
- @Nullable
- static MetricExporter configureSpiExporter(
- String name, ConfigProperties config, ClassLoader serviceClassLoader) {
- NamedSpiManager spiExportersManager =
- SpiUtil.loadConfigurable(
- ConfigurableMetricExporterProvider.class,
- ConfigurableMetricExporterProvider::getName,
- ConfigurableMetricExporterProvider::createExporter,
- config,
- serviceClassLoader);
- return spiExportersManager.getByName(name);
- }
-
// Visible for testing
- static MetricExporter configureOtlpMetrics(ConfigProperties config) {
- String protocol = OtlpConfigUtil.getOtlpProtocol(DATA_TYPE_METRICS, config);
-
- if (protocol.equals(PROTOCOL_HTTP_PROTOBUF)) {
- ClasspathUtil.checkClassExists(
- "io.opentelemetry.exporter.otlp.http.metrics.OtlpHttpMetricExporter",
- "OTLP HTTP Metrics Exporter",
- "opentelemetry-exporter-otlp-http-metrics");
- OtlpHttpMetricExporterBuilder builder = OtlpHttpMetricExporter.builder();
-
- OtlpConfigUtil.configureOtlpExporterBuilder(
- DATA_TYPE_METRICS,
- config,
- builder::setEndpoint,
- builder::addHeader,
- builder::setCompression,
- builder::setTimeout,
- builder::setTrustedCertificates,
- builder::setClientTls,
- retryPolicy -> RetryUtil.setRetryPolicyOnDelegate(builder, retryPolicy));
- OtlpConfigUtil.configureOtlpAggregationTemporality(
- config, builder::setAggregationTemporalitySelector);
- OtlpConfigUtil.configureOtlpHistogramDefaultAggregation(
- config, builder::setDefaultAggregationSelector);
-
- return builder.build();
- } else if (protocol.equals(PROTOCOL_GRPC)) {
- ClasspathUtil.checkClassExists(
- "io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporter",
- "OTLP gRPC Metrics Exporter",
- "opentelemetry-exporter-otlp");
- OtlpGrpcMetricExporterBuilder builder = OtlpGrpcMetricExporter.builder();
-
- OtlpConfigUtil.configureOtlpExporterBuilder(
- DATA_TYPE_METRICS,
- config,
- builder::setEndpoint,
- builder::addHeader,
- builder::setCompression,
- builder::setTimeout,
- builder::setTrustedCertificates,
- builder::setClientTls,
- retryPolicy -> RetryUtil.setRetryPolicyOnDelegate(builder, retryPolicy));
- OtlpConfigUtil.configureOtlpAggregationTemporality(
- config, builder::setAggregationTemporalitySelector);
- OtlpConfigUtil.configureOtlpHistogramDefaultAggregation(
- config, builder::setDefaultAggregationSelector);
+ static NamedSpiManager metricExporterSpiManager(
+ ConfigProperties config, ClassLoader serviceClassLoader) {
+ return SpiUtil.loadConfigurable(
+ ConfigurableMetricExporterProvider.class,
+ ConfigurableMetricExporterProvider::getName,
+ ConfigurableMetricExporterProvider::createExporter,
+ config,
+ serviceClassLoader);
+ }
- return builder.build();
- } else {
- throw new ConfigurationException("Unsupported OTLP metrics protocol: " + protocol);
+ // Visible for testing.
+ static MetricExporter configureExporter(
+ String name, NamedSpiManager spiExportersManager) {
+ MetricExporter metricExporter = spiExportersManager.getByName(name);
+ if (metricExporter == null) {
+ String artifactId = EXPORTER_ARTIFACT_ID_BY_NAME.get(name);
+ if (artifactId != null) {
+ throw new ConfigurationException(
+ "otel.metrics.exporter set to \""
+ + name
+ + "\" but "
+ + artifactId
+ + " not found on classpath. Make sure to add it as a dependency.");
+ }
+ throw new ConfigurationException("Unrecognized value for otel.metrics.exporter: " + name);
}
+ return metricExporter;
}
private static PeriodicMetricReader configurePeriodicMetricReader(
diff --git a/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/SpanExporterConfiguration.java b/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/SpanExporterConfiguration.java
index 8fa9d7a17da..93bec0b55a4 100644
--- a/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/SpanExporterConfiguration.java
+++ b/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/SpanExporterConfiguration.java
@@ -5,17 +5,8 @@
package io.opentelemetry.sdk.autoconfigure;
-import static io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.DATA_TYPE_TRACES;
-import static io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.PROTOCOL_GRPC;
-import static io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.PROTOCOL_HTTP_PROTOBUF;
import static java.util.stream.Collectors.toMap;
-import io.opentelemetry.api.metrics.MeterProvider;
-import io.opentelemetry.exporter.internal.retry.RetryUtil;
-import io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporter;
-import io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporterBuilder;
-import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter;
-import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporterBuilder;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
@@ -38,6 +29,7 @@ final class SpanExporterConfiguration {
EXPORTER_ARTIFACT_ID_BY_NAME.put("jaeger", "opentelemetry-exporter-jaeger");
EXPORTER_ARTIFACT_ID_BY_NAME.put("logging", "opentelemetry-exporter-logging");
EXPORTER_ARTIFACT_ID_BY_NAME.put("logging-otlp", "opentelemetry-exporter-logging-otlp");
+ EXPORTER_ARTIFACT_ID_BY_NAME.put("otlp", "opentelemetry-exporter-otlp");
EXPORTER_ARTIFACT_ID_BY_NAME.put("zipkin", "opentelemetry-exporter-zipkin");
}
@@ -45,7 +37,6 @@ final class SpanExporterConfiguration {
static Map configureSpanExporters(
ConfigProperties config,
ClassLoader serviceClassLoader,
- MeterProvider meterProvider,
BiFunction super SpanExporter, ConfigProperties, ? extends SpanExporter>
spanExporterCustomizer) {
Set exporterNames = DefaultConfigProperties.getSet(config, "otel.traces.exporter");
@@ -75,8 +66,7 @@ static Map configureSpanExporters(
Function.identity(),
exporterName ->
spanExporterCustomizer.apply(
- configureExporter(exporterName, config, spiExportersManager, meterProvider),
- config)));
+ configureExporter(exporterName, spiExportersManager), config)));
}
// Visible for testing
@@ -92,79 +82,21 @@ static NamedSpiManager spanExporterSpiManager(
// Visible for testing
static SpanExporter configureExporter(
- String name,
- ConfigProperties config,
- NamedSpiManager spiExportersManager,
- MeterProvider meterProvider) {
- switch (name) {
- case "otlp":
- return configureOtlp(config, meterProvider);
- default:
- SpanExporter spiExporter = spiExportersManager.getByName(name);
- if (spiExporter == null) {
- String artifactId = EXPORTER_ARTIFACT_ID_BY_NAME.get(name);
- if (artifactId != null) {
- throw new ConfigurationException(
- "otel.traces.exporter set to \""
- + name
- + "\" but "
- + artifactId
- + " not found on classpath. Make sure to add it as a dependency.");
- }
- throw new ConfigurationException("Unrecognized value for otel.traces.exporter: " + name);
- }
- return spiExporter;
- }
- }
-
- // 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,
- builder::setClientTls,
- 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,
- builder::setClientTls,
- retryPolicy -> RetryUtil.setRetryPolicyOnDelegate(builder, retryPolicy));
- builder.setMeterProvider(meterProvider);
-
- return builder.build();
- } else {
- throw new ConfigurationException("Unsupported OTLP traces protocol: " + protocol);
+ String name, NamedSpiManager spiExportersManager) {
+ SpanExporter spiExporter = spiExportersManager.getByName(name);
+ if (spiExporter == null) {
+ String artifactId = EXPORTER_ARTIFACT_ID_BY_NAME.get(name);
+ if (artifactId != null) {
+ throw new ConfigurationException(
+ "otel.traces.exporter set to \""
+ + name
+ + "\" but "
+ + artifactId
+ + " not found on classpath. Make sure to add it as a dependency.");
+ }
+ throw new ConfigurationException("Unrecognized value for otel.traces.exporter: " + name);
}
+ return spiExporter;
}
private SpanExporterConfiguration() {}
diff --git a/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/TracerProviderConfiguration.java b/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/TracerProviderConfiguration.java
index 880bfb7c2c0..8493fe13611 100644
--- a/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/TracerProviderConfiguration.java
+++ b/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/TracerProviderConfiguration.java
@@ -47,7 +47,7 @@ static void configureTracerProvider(
Map exportersByName =
SpanExporterConfiguration.configureSpanExporters(
- config, serviceClassLoader, meterProvider, spanExporterCustomizer);
+ config, serviceClassLoader, spanExporterCustomizer);
configureSpanProcessors(config, exportersByName, meterProvider)
.forEach(tracerProviderBuilder::addSpanProcessor);
diff --git a/sdk-extensions/autoconfigure/src/test/java/io/opentelemetry/sdk/autoconfigure/LogRecordExporterConfigurationTest.java b/sdk-extensions/autoconfigure/src/test/java/io/opentelemetry/sdk/autoconfigure/LogRecordExporterConfigurationTest.java
index d5f7d1146fe..3b2a311a287 100644
--- a/sdk-extensions/autoconfigure/src/test/java/io/opentelemetry/sdk/autoconfigure/LogRecordExporterConfigurationTest.java
+++ b/sdk-extensions/autoconfigure/src/test/java/io/opentelemetry/sdk/autoconfigure/LogRecordExporterConfigurationTest.java
@@ -8,7 +8,6 @@
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import com.google.common.collect.ImmutableMap;
-import io.opentelemetry.api.metrics.MeterProvider;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
@@ -26,7 +25,6 @@ void configureLogRecordExporters_duplicates() {
LogRecordExporterConfiguration.configureLogRecordExporters(
config,
LogRecordExporterConfiguration.class.getClassLoader(),
- MeterProvider.noop(),
(a, unused) -> a))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("otel.logs.exporter contains duplicates: [otlp]");
@@ -42,7 +40,6 @@ void configureLogRecordExporters_unrecognized() {
LogRecordExporterConfiguration.configureLogRecordExporters(
config,
LogRecordExporterConfiguration.class.getClassLoader(),
- MeterProvider.noop(),
(a, unused) -> a))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("Unrecognized value for otel.logs.exporter: foo");
@@ -58,21 +55,8 @@ void configureLogRecordExporters_multipleWithNone() {
LogRecordExporterConfiguration.configureLogRecordExporters(
config,
LogRecordExporterConfiguration.class.getClassLoader(),
- MeterProvider.noop(),
(a, unused) -> a))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("otel.logs.exporter contains none along with other exporters");
}
-
- @Test
- void configureOtlpLogs_unsupportedProtocol() {
- assertThatThrownBy(
- () ->
- LogRecordExporterConfiguration.configureOtlpLogs(
- DefaultConfigProperties.createForTest(
- ImmutableMap.of("otel.exporter.otlp.protocol", "foo")),
- MeterProvider.noop()))
- .isInstanceOf(ConfigurationException.class)
- .hasMessageContaining("Unsupported OTLP logs protocol: foo");
- }
}
diff --git a/sdk-extensions/autoconfigure/src/test/java/io/opentelemetry/sdk/autoconfigure/NotOnClasspathTest.java b/sdk-extensions/autoconfigure/src/test/java/io/opentelemetry/sdk/autoconfigure/NotOnClasspathTest.java
index f6845765d12..8486a965fc9 100644
--- a/sdk-extensions/autoconfigure/src/test/java/io/opentelemetry/sdk/autoconfigure/NotOnClasspathTest.java
+++ b/sdk-extensions/autoconfigure/src/test/java/io/opentelemetry/sdk/autoconfigure/NotOnClasspathTest.java
@@ -8,10 +8,12 @@
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import io.opentelemetry.api.metrics.MeterProvider;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
+import io.opentelemetry.sdk.logs.export.LogRecordExporter;
+import io.opentelemetry.sdk.metrics.export.MetricExporter;
+import io.opentelemetry.sdk.trace.export.SpanExporter;
import java.util.Collections;
import org.junit.jupiter.api.Test;
@@ -19,44 +21,30 @@ class NotOnClasspathTest {
private static final ConfigProperties EMPTY =
DefaultConfigProperties.createForTest(Collections.emptyMap());
-
- @Test
- void otlpGrpcSpans() {
+ private static final NamedSpiManager SPAN_EXPORTER_SPI_MANAGER =
+ SpanExporterConfiguration.spanExporterSpiManager(
+ EMPTY, NotOnClasspathTest.class.getClassLoader());
+ private static final NamedSpiManager METRIC_EXPORTER_SPI_MANAGER =
+ MetricExporterConfiguration.metricExporterSpiManager(
+ EMPTY, NotOnClasspathTest.class.getClassLoader());
+ private static final NamedSpiManager LOG_RECORD_EXPORTER_SPI_MANAGER =
+ LogRecordExporterConfiguration.logRecordExporterSpiManager(
+ EMPTY, NotOnClasspathTest.class.getClassLoader());
+
+ @Test
+ void otlpSpans() {
assertThatThrownBy(
- () ->
- SpanExporterConfiguration.configureExporter(
- "otlp", EMPTY, NamedSpiManager.createEmpty(), MeterProvider.noop()))
- .isInstanceOf(ConfigurationException.class)
- .hasMessageContaining(
- "OTLP gRPC Trace Exporter enabled but opentelemetry-exporter-otlp not found on "
- + "classpath");
- }
-
- @Test
- void otlpHttpSpans() {
- ConfigProperties config =
- DefaultConfigProperties.createForTest(
- Collections.singletonMap("otel.exporter.otlp.protocol", "http/protobuf"));
- assertThatThrownBy(
- () ->
- SpanExporterConfiguration.configureExporter(
- "otlp", config, NamedSpiManager.createEmpty(), MeterProvider.noop()))
+ () -> SpanExporterConfiguration.configureExporter("otlp", SPAN_EXPORTER_SPI_MANAGER))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining(
- "OTLP HTTP Trace Exporter enabled but opentelemetry-exporter-otlp-http-trace not found on "
- + "classpath");
+ "otel.traces.exporter set to \"otlp\" but opentelemetry-exporter-otlp not found on classpath."
+ + " Make sure to add it as a dependency.");
}
@Test
void jaeger() {
assertThatThrownBy(
- () ->
- SpanExporterConfiguration.configureExporter(
- "jaeger",
- EMPTY,
- SpanExporterConfiguration.spanExporterSpiManager(
- EMPTY, NotOnClasspathTest.class.getClassLoader()),
- MeterProvider.noop()))
+ () -> SpanExporterConfiguration.configureExporter("jaeger", SPAN_EXPORTER_SPI_MANAGER))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining(
"otel.traces.exporter set to \"jaeger\" but opentelemetry-exporter-jaeger not found on classpath."
@@ -66,9 +54,7 @@ void jaeger() {
@Test
void zipkin() {
assertThatThrownBy(
- () ->
- SpanExporterConfiguration.configureExporter(
- "zipkin", EMPTY, NamedSpiManager.createEmpty(), MeterProvider.noop()))
+ () -> SpanExporterConfiguration.configureExporter("zipkin", SPAN_EXPORTER_SPI_MANAGER))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining(
"otel.traces.exporter set to \"zipkin\" but opentelemetry-exporter-zipkin not found on classpath."
@@ -78,9 +64,7 @@ void zipkin() {
@Test
void loggingSpans() {
assertThatThrownBy(
- () ->
- SpanExporterConfiguration.configureExporter(
- "logging", EMPTY, NamedSpiManager.createEmpty(), MeterProvider.noop()))
+ () -> SpanExporterConfiguration.configureExporter("logging", SPAN_EXPORTER_SPI_MANAGER))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining(
"otel.traces.exporter set to \"logging\" but opentelemetry-exporter-logging not found on classpath."
@@ -92,12 +76,7 @@ void loggingSpansOtlp() {
assertThatThrownBy(
() ->
SpanExporterConfiguration.configureExporter(
- "logging-otlp",
- EMPTY,
- SpanExporterConfiguration.spanExporterSpiManager(
- DefaultConfigProperties.createForTest(Collections.emptyMap()),
- NotOnClasspathTest.class.getClassLoader()),
- MeterProvider.noop()))
+ "logging-otlp", SPAN_EXPORTER_SPI_MANAGER))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining(
"otel.traces.exporter set to \"logging-otlp\" but opentelemetry-exporter-logging-otlp not found on classpath."
@@ -109,10 +88,7 @@ void loggingMetrics() {
assertThatThrownBy(
() ->
MetricExporterConfiguration.configureExporter(
- "logging",
- EMPTY,
- MetricExporterConfiguration.class.getClassLoader(),
- (a, unused) -> a))
+ "logging", METRIC_EXPORTER_SPI_MANAGER))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining(
"otel.metrics.exporter set to \"logging\" but opentelemetry-exporter-logging not found on classpath."
@@ -124,10 +100,7 @@ void loggingMetricsOtlp() {
assertThatThrownBy(
() ->
MetricExporterConfiguration.configureExporter(
- "logging-otlp",
- EMPTY,
- MetricExporterConfiguration.class.getClassLoader(),
- (a, unused) -> a))
+ "logging-otlp", METRIC_EXPORTER_SPI_MANAGER))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining(
"otel.metrics.exporter set to \"logging-otlp\" but opentelemetry-exporter-logging-otlp not found on classpath."
@@ -139,7 +112,7 @@ void loggingLogs() {
assertThatThrownBy(
() ->
LogRecordExporterConfiguration.configureExporter(
- "logging", EMPTY, NamedSpiManager.createEmpty(), MeterProvider.noop()))
+ "logging", LOG_RECORD_EXPORTER_SPI_MANAGER))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining(
"otel.logs.exporter set to \"logging\" but opentelemetry-exporter-logging not found on classpath."
@@ -151,12 +124,7 @@ void loggingLogsOtlp() {
assertThatThrownBy(
() ->
LogRecordExporterConfiguration.configureExporter(
- "logging-otlp",
- EMPTY,
- LogRecordExporterConfiguration.logRecordExporterSpiManager(
- DefaultConfigProperties.createForTest(Collections.emptyMap()),
- NotOnClasspathTest.class.getClassLoader()),
- MeterProvider.noop()))
+ "logging-otlp", LOG_RECORD_EXPORTER_SPI_MANAGER))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining(
"otel.logs.exporter set to \"logging-otlp\" but opentelemetry-exporter-logging-otlp not found on classpath."
@@ -164,44 +132,24 @@ void loggingLogsOtlp() {
}
@Test
- void otlpGrpcMetrics() {
+ void otlpMetrics() {
assertThatCode(
() ->
- MetricExporterConfiguration.configureExporter(
- "otlp",
- EMPTY,
- MetricExporterConfiguration.class.getClassLoader(),
- (a, unused) -> a))
+ MetricExporterConfiguration.configureExporter("otlp", METRIC_EXPORTER_SPI_MANAGER))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining(
- "OTLP gRPC Metrics Exporter enabled but opentelemetry-exporter-otlp not found on "
- + "classpath");
- }
-
- @Test
- void otlpHttpMetrics() {
- ConfigProperties config =
- DefaultConfigProperties.createForTest(
- Collections.singletonMap("otel.exporter.otlp.protocol", "http/protobuf"));
- assertThatCode(
- () ->
- MetricExporterConfiguration.configureExporter(
- "otlp",
- config,
- MetricExporterConfiguration.class.getClassLoader(),
- (a, unused) -> a))
- .hasMessageContaining(
- "OTLP HTTP Metrics Exporter enabled but opentelemetry-exporter-otlp-http-metrics not found on classpath");
+ "otel.metrics.exporter set to \"otlp\" but opentelemetry-exporter-otlp not found on classpath."
+ + " Make sure to add it as a dependency.");
}
@Test
void prometheus() {
assertThatThrownBy(
() ->
- MetricExporterConfiguration.configureExporter(
+ MetricExporterConfiguration.configureReader(
"prometheus",
EMPTY,
- MetricExporterConfiguration.class.getClassLoader(),
+ NotOnClasspathTest.class.getClassLoader(),
(a, unused) -> a))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining(
@@ -227,19 +175,10 @@ void otlpGrpcLogs() {
assertThatCode(
() ->
LogRecordExporterConfiguration.configureExporter(
- "otlp", EMPTY, NamedSpiManager.createEmpty(), MeterProvider.noop()))
- .doesNotThrowAnyException();
- }
-
- @Test
- void otlpHttpLogs() {
- ConfigProperties config =
- DefaultConfigProperties.createForTest(
- Collections.singletonMap("otel.exporter.otlp.protocol", "http/protobuf"));
- assertThatCode(
- () ->
- LogRecordExporterConfiguration.configureExporter(
- "otlp", config, NamedSpiManager.createEmpty(), MeterProvider.noop()))
- .doesNotThrowAnyException();
+ "otlp", LOG_RECORD_EXPORTER_SPI_MANAGER))
+ .isInstanceOf(ConfigurationException.class)
+ .hasMessageContaining(
+ "otel.logs.exporter set to \"otlp\" but opentelemetry-exporter-otlp not found on classpath."
+ + " Make sure to add it as a dependency.");
}
}
diff --git a/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/ConfigurableLogRecordExporterTest.java b/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/ConfigurableLogRecordExporterTest.java
index 39a0f186126..82ec5b679d5 100644
--- a/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/ConfigurableLogRecordExporterTest.java
+++ b/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/ConfigurableLogRecordExporterTest.java
@@ -9,14 +9,12 @@
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import com.google.common.collect.ImmutableMap;
-import io.opentelemetry.api.metrics.MeterProvider;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
import io.opentelemetry.sdk.logs.export.LogRecordExporter;
import java.net.URL;
import java.net.URLClassLoader;
-import java.util.Collections;
import java.util.Map;
import org.junit.jupiter.api.Test;
@@ -29,10 +27,7 @@ void configureLogRecordExporters_spiExporter() {
ImmutableMap.of("test.option", "true", "otel.logs.exporter", "testExporter"));
Map exportersByName =
LogRecordExporterConfiguration.configureLogRecordExporters(
- config,
- LogRecordExporterConfiguration.class.getClassLoader(),
- MeterProvider.noop(),
- (a, unused) -> a);
+ config, LogRecordExporterConfiguration.class.getClassLoader(), (a, unused) -> a);
assertThat(exportersByName)
.hasSize(1)
@@ -51,10 +46,7 @@ void configureLogRecordExporters_emptyClassLoader() {
assertThatThrownBy(
() ->
LogRecordExporterConfiguration.configureLogRecordExporters(
- config,
- new URLClassLoader(new URL[0], null),
- MeterProvider.noop(),
- (a, unused) -> a))
+ config, new URLClassLoader(new URL[0], null), (a, unused) -> a))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("testExporter");
}
@@ -64,10 +56,7 @@ void configureExporter_NotFound() {
assertThatThrownBy(
() ->
LogRecordExporterConfiguration.configureExporter(
- "catExporter",
- DefaultConfigProperties.createForTest(Collections.emptyMap()),
- NamedSpiManager.createEmpty(),
- MeterProvider.noop()))
+ "catExporter", NamedSpiManager.createEmpty()))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("catExporter");
}
diff --git a/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/ConfigurableMetricExporterTest.java b/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/ConfigurableMetricExporterTest.java
index 999c6ea27a1..bdfb28aa9c3 100644
--- a/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/ConfigurableMetricExporterTest.java
+++ b/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/ConfigurableMetricExporterTest.java
@@ -14,7 +14,6 @@
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
-import io.opentelemetry.sdk.metrics.SdkMeterProvider;
import io.opentelemetry.sdk.metrics.export.MetricExporter;
import io.opentelemetry.sdk.metrics.export.PeriodicMetricReader;
import java.net.URL;
@@ -30,8 +29,10 @@ void configuration() {
ConfigProperties config =
DefaultConfigProperties.createForTest(ImmutableMap.of("test.option", "true"));
MetricExporter metricExporter =
- MetricExporterConfiguration.configureSpiExporter(
- "testExporter", config, MetricExporterConfiguration.class.getClassLoader());
+ MetricExporterConfiguration.configureExporter(
+ "testExporter",
+ MetricExporterConfiguration.metricExporterSpiManager(
+ config, ConfigurableMetricExporterTest.class.getClassLoader()));
assertThat(metricExporter)
.isInstanceOf(TestConfigurableMetricExporterProvider.TestMetricExporter.class)
@@ -45,9 +46,9 @@ void emptyClassLoader() {
() ->
MetricExporterConfiguration.configureExporter(
"testExporter",
- DefaultConfigProperties.createForTest(Collections.emptyMap()),
- new URLClassLoader(new URL[0], null),
- (a, unused) -> a))
+ MetricExporterConfiguration.metricExporterSpiManager(
+ DefaultConfigProperties.createForTest(Collections.emptyMap()),
+ new URLClassLoader(new URL[] {}, null))))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("testExporter");
}
@@ -58,25 +59,24 @@ void exporterNotFound() {
() ->
MetricExporterConfiguration.configureExporter(
"catExporter",
- DefaultConfigProperties.createForTest(Collections.emptyMap()),
- MetricExporterConfiguration.class.getClassLoader(),
- (a, unused) -> a))
+ MetricExporterConfiguration.metricExporterSpiManager(
+ DefaultConfigProperties.createForTest(Collections.emptyMap()),
+ ConfigurableMetricExporterTest.class.getClassLoader())))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("catExporter");
}
@Test
- void configureMetricExporters_multipleWithNone() {
+ void configureMetricReaders_multipleWithNone() {
ConfigProperties config =
DefaultConfigProperties.createForTest(
ImmutableMap.of("otel.metrics.exporter", "otlp,none"));
assertThatThrownBy(
() ->
- MeterProviderConfiguration.configureMeterProvider(
- SdkMeterProvider.builder(),
+ MeterProviderConfiguration.configureMetricReaders(
config,
- MetricExporterConfiguration.class.getClassLoader(),
+ ConfigurableMetricExporterTest.class.getClassLoader(),
(a, unused) -> a))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("otel.metrics.exporter contains none along with other exporters");
diff --git a/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/ConfigurableSpanExporterTest.java b/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/ConfigurableSpanExporterTest.java
index f3b5fd0be8f..c0b1e03dbcd 100644
--- a/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/ConfigurableSpanExporterTest.java
+++ b/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/ConfigurableSpanExporterTest.java
@@ -35,10 +35,7 @@ void configureSpanExporters_spiExporter() {
ImmutableMap.of("test.option", "true", "otel.traces.exporter", "testExporter"));
Map exportersByName =
SpanExporterConfiguration.configureSpanExporters(
- config,
- SpanExporterConfiguration.class.getClassLoader(),
- MeterProvider.noop(),
- (a, unused) -> a);
+ config, SpanExporterConfiguration.class.getClassLoader(), (a, unused) -> a);
assertThat(exportersByName)
.hasSize(1)
@@ -57,10 +54,7 @@ void configureSpanExporters_emptyClassLoader() {
assertThatThrownBy(
() ->
SpanExporterConfiguration.configureSpanExporters(
- config,
- new URLClassLoader(new URL[0], null),
- MeterProvider.noop(),
- (a, unused) -> a))
+ config, new URLClassLoader(new URL[0], null), (a, unused) -> a))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("testExporter");
}
@@ -74,10 +68,7 @@ void configureSpanExporters_duplicates() {
assertThatThrownBy(
() ->
SpanExporterConfiguration.configureSpanExporters(
- config,
- SpanExporterConfiguration.class.getClassLoader(),
- MeterProvider.noop(),
- (a, unused) -> a))
+ config, SpanExporterConfiguration.class.getClassLoader(), (a, unused) -> a))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("otel.traces.exporter contains duplicates: [otlp]");
}
@@ -90,10 +81,7 @@ void configureSpanExporters_multipleWithNone() {
assertThatThrownBy(
() ->
SpanExporterConfiguration.configureSpanExporters(
- config,
- SpanExporterConfiguration.class.getClassLoader(),
- MeterProvider.noop(),
- (a, unused) -> a))
+ config, SpanExporterConfiguration.class.getClassLoader(), (a, unused) -> a))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("otel.traces.exporter contains none along with other exporters");
}
@@ -103,10 +91,7 @@ void exporterNotFound() {
assertThatThrownBy(
() ->
SpanExporterConfiguration.configureExporter(
- "catExporter",
- DefaultConfigProperties.createForTest(Collections.emptyMap()),
- NamedSpiManager.createEmpty(),
- MeterProvider.noop()))
+ "catExporter", NamedSpiManager.createEmpty()))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("catExporter");
}
diff --git a/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/LogRecordExporterConfigurationTest.java b/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/LogRecordExporterConfigurationTest.java
new file mode 100644
index 00000000000..89674433bd3
--- /dev/null
+++ b/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/LogRecordExporterConfigurationTest.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package io.opentelemetry.sdk.autoconfigure;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import com.google.common.collect.ImmutableMap;
+import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
+import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
+import org.junit.jupiter.api.Test;
+
+public class LogRecordExporterConfigurationTest {
+
+ @Test
+ void configureExporter_UnsupportedOtlpProtocol() {
+ assertThatThrownBy(
+ () ->
+ LogRecordExporterConfiguration.configureExporter(
+ "otlp",
+ LogRecordExporterConfiguration.logRecordExporterSpiManager(
+ DefaultConfigProperties.createForTest(
+ ImmutableMap.of("otel.exporter.otlp.protocol", "foo")),
+ LogRecordExporterConfiguration.class.getClassLoader())))
+ .isInstanceOf(ConfigurationException.class)
+ .hasMessageContaining("Unsupported OTLP logs protocol: foo");
+ }
+}
diff --git a/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/MetricExporterConfigurationTest.java b/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/MetricExporterConfigurationTest.java
index 6be98b6f069..68d3a8afb5f 100644
--- a/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/MetricExporterConfigurationTest.java
+++ b/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/MetricExporterConfigurationTest.java
@@ -18,9 +18,12 @@ public class MetricExporterConfigurationTest {
void configureOtlpMetricsUnsupportedProtocol() {
assertThatThrownBy(
() ->
- MetricExporterConfiguration.configureOtlpMetrics(
- DefaultConfigProperties.createForTest(
- ImmutableMap.of("otel.exporter.otlp.protocol", "foo"))))
+ MetricExporterConfiguration.configureExporter(
+ "otlp",
+ MetricExporterConfiguration.metricExporterSpiManager(
+ DefaultConfigProperties.createForTest(
+ ImmutableMap.of("otel.exporter.otlp.protocol", "foo")),
+ MetricExporterConfigurationTest.class.getClassLoader())))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("Unsupported OTLP metrics protocol: foo");
}
diff --git a/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/SpanExporterConfigurationTest.java b/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/SpanExporterConfigurationTest.java
index 1f0ce15d2be..9cfcc43245f 100644
--- a/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/SpanExporterConfigurationTest.java
+++ b/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/SpanExporterConfigurationTest.java
@@ -9,7 +9,6 @@
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import com.google.common.collect.ImmutableMap;
-import io.opentelemetry.api.metrics.MeterProvider;
import io.opentelemetry.exporter.jaeger.JaegerGrpcSpanExporter;
import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
@@ -23,12 +22,15 @@ class SpanExporterConfigurationTest {
@Test
void configureOtlpSpansUnsupportedProtocol() {
+ ConfigProperties config =
+ DefaultConfigProperties.createForTest(
+ ImmutableMap.of("otel.exporter.otlp.protocol", "foo"));
assertThatThrownBy(
() ->
- SpanExporterConfiguration.configureOtlp(
- DefaultConfigProperties.createForTest(
- ImmutableMap.of("otel.exporter.otlp.protocol", "foo")),
- MeterProvider.noop()))
+ SpanExporterConfiguration.configureExporter(
+ "otlp",
+ SpanExporterConfiguration.spanExporterSpiManager(
+ config, SpanExporterConfigurationTest.class.getClassLoader())))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("Unsupported OTLP traces protocol: foo");
}
@@ -36,13 +38,14 @@ void configureOtlpSpansUnsupportedProtocol() {
// Timeout difficult to test using real exports so just check implementation detail here.
@Test
void configureOtlpTimeout() {
+ ConfigProperties config =
+ DefaultConfigProperties.createForTest(
+ Collections.singletonMap("otel.exporter.otlp.timeout", "10"));
SpanExporter exporter =
SpanExporterConfiguration.configureExporter(
"otlp",
- DefaultConfigProperties.createForTest(
- Collections.singletonMap("otel.exporter.otlp.timeout", "10")),
- NamedSpiManager.createEmpty(),
- MeterProvider.noop());
+ SpanExporterConfiguration.spanExporterSpiManager(
+ config, SpanExporterConfigurationTest.class.getClassLoader()));
try {
assertThat(exporter)
.isInstanceOfSatisfying(
@@ -63,10 +66,8 @@ void configureJaegerTimeout() {
SpanExporter exporter =
SpanExporterConfiguration.configureExporter(
"jaeger",
- config,
SpanExporterConfiguration.spanExporterSpiManager(
- config, SpanExporterConfigurationTest.class.getClassLoader()),
- MeterProvider.noop());
+ config, SpanExporterConfigurationTest.class.getClassLoader()));
try {
assertThat(exporter)
.isInstanceOfSatisfying(
@@ -87,10 +88,8 @@ void configureZipkinTimeout() {
SpanExporter exporter =
SpanExporterConfiguration.configureExporter(
"zipkin",
- config,
SpanExporterConfiguration.spanExporterSpiManager(
- config, SpanExporterConfigurationTest.class.getClassLoader()),
- MeterProvider.noop());
+ config, SpanExporterConfigurationTest.class.getClassLoader()));
try {
assertThat(exporter).isNotNull();
} finally {
diff --git a/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcConfigTest.java b/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcConfigTest.java
index 11f24a73e2f..ca497d18cbf 100644
--- a/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcConfigTest.java
+++ b/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcConfigTest.java
@@ -17,7 +17,6 @@
import com.linecorp.armeria.testing.junit5.server.SelfSignedCertificateExtension;
import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.api.logs.GlobalLoggerProvider;
-import io.opentelemetry.api.metrics.MeterProvider;
import io.opentelemetry.sdk.OpenTelemetrySdk;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
@@ -83,11 +82,19 @@ void configureExportersGeneral() {
ConfigProperties properties = DefaultConfigProperties.createForTest(props);
try (SpanExporter spanExporter =
SpanExporterConfiguration.configureExporter(
- "otlp", properties, NamedSpiManager.createEmpty(), MeterProvider.noop());
+ "otlp",
+ SpanExporterConfiguration.spanExporterSpiManager(
+ properties, OtlpGrpcConfigTest.class.getClassLoader()));
MetricExporter metricExporter =
- MetricExporterConfiguration.configureOtlpMetrics(properties);
+ MetricExporterConfiguration.configureExporter(
+ "otlp",
+ MetricExporterConfiguration.metricExporterSpiManager(
+ properties, OtlpGrpcConfigTest.class.getClassLoader()));
LogRecordExporter logRecordExporter =
- LogRecordExporterConfiguration.configureOtlpLogs(properties, MeterProvider.noop())) {
+ LogRecordExporterConfiguration.configureExporter(
+ "otlp",
+ LogRecordExporterConfiguration.logRecordExporterSpiManager(
+ properties, OtlpGrpcConfigTest.class.getClassLoader()))) {
assertThat(spanExporter)
.extracting("delegate.client.callTimeoutMillis", INTEGER)
.isEqualTo(TimeUnit.SECONDS.toMillis(15));
@@ -148,12 +155,12 @@ void configureSpanExporter() {
props.put("otel.exporter.otlp.traces.headers", "header-key=header-value");
props.put("otel.exporter.otlp.traces.compression", "gzip");
props.put("otel.exporter.otlp.traces.timeout", "15s");
+ ConfigProperties properties = DefaultConfigProperties.createForTest(props);
try (SpanExporter spanExporter =
SpanExporterConfiguration.configureExporter(
"otlp",
- DefaultConfigProperties.createForTest(props),
- NamedSpiManager.createEmpty(),
- MeterProvider.noop())) {
+ SpanExporterConfiguration.spanExporterSpiManager(
+ properties, OtlpGrpcConfigTest.class.getClassLoader()))) {
assertThat(spanExporter)
.extracting("delegate.client.callTimeoutMillis", INTEGER)
.isEqualTo(TimeUnit.SECONDS.toMillis(15));
@@ -185,9 +192,12 @@ public void configureMetricExporter() {
props.put("otel.exporter.otlp.metrics.compression", "gzip");
props.put("otel.exporter.otlp.metrics.timeout", "15s");
props.put("otel.exporter.otlp.metrics.temporality.preference", "DELTA");
+ ConfigProperties properties = DefaultConfigProperties.createForTest(props);
try (MetricExporter metricExporter =
- MetricExporterConfiguration.configureOtlpMetrics(
- DefaultConfigProperties.createForTest(props))) {
+ MetricExporterConfiguration.configureExporter(
+ "otlp",
+ MetricExporterConfiguration.metricExporterSpiManager(
+ properties, OtlpGrpcConfigTest.class.getClassLoader()))) {
assertThat(metricExporter)
.extracting("delegate.client.callTimeoutMillis", INTEGER)
@@ -226,9 +236,12 @@ public void configureLogRecordExporter() {
props.put("otel.exporter.otlp.logs.headers", "header-key=header-value");
props.put("otel.exporter.otlp.logs.compression", "gzip");
props.put("otel.exporter.otlp.logs.timeout", "15s");
+ ConfigProperties properties = DefaultConfigProperties.createForTest(props);
try (LogRecordExporter logRecordExporter =
- LogRecordExporterConfiguration.configureOtlpLogs(
- DefaultConfigProperties.createForTest(props), MeterProvider.noop())) {
+ LogRecordExporterConfiguration.configureExporter(
+ "otlp",
+ LogRecordExporterConfiguration.logRecordExporterSpiManager(
+ properties, OtlpGrpcConfigTest.class.getClassLoader()))) {
assertThat(logRecordExporter)
.extracting("delegate.client.callTimeoutMillis", INTEGER)
@@ -255,17 +268,27 @@ void configureTlsInvalidCertificatePath() {
assertThatThrownBy(
() ->
SpanExporterConfiguration.configureExporter(
- "otlp", properties, NamedSpiManager.createEmpty(), MeterProvider.noop()))
+ "otlp",
+ SpanExporterConfiguration.spanExporterSpiManager(
+ properties, OtlpGrpcConfigTest.class.getClassLoader())))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("Invalid OTLP certificate/key path:");
- assertThatThrownBy(() -> MetricExporterConfiguration.configureOtlpMetrics(properties))
+ assertThatThrownBy(
+ () ->
+ MetricExporterConfiguration.configureExporter(
+ "otlp",
+ MetricExporterConfiguration.metricExporterSpiManager(
+ properties, OtlpGrpcConfigTest.class.getClassLoader())))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("Invalid OTLP certificate/key path:");
assertThatThrownBy(
() ->
- LogRecordExporterConfiguration.configureOtlpLogs(properties, MeterProvider.noop()))
+ LogRecordExporterConfiguration.configureExporter(
+ "otlp",
+ LogRecordExporterConfiguration.logRecordExporterSpiManager(
+ properties, OtlpGrpcConfigTest.class.getClassLoader())))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("Invalid OTLP certificate/key path:");
}
@@ -279,17 +302,27 @@ void configureTlsMissingClientCertificatePath() {
assertThatThrownBy(
() ->
SpanExporterConfiguration.configureExporter(
- "otlp", properties, NamedSpiManager.createEmpty(), MeterProvider.noop()))
+ "otlp",
+ SpanExporterConfiguration.spanExporterSpiManager(
+ properties, OtlpGrpcConfigTest.class.getClassLoader())))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("Client key provided but certification chain is missing");
- assertThatThrownBy(() -> MetricExporterConfiguration.configureOtlpMetrics(properties))
+ assertThatThrownBy(
+ () ->
+ MetricExporterConfiguration.configureExporter(
+ "otlp",
+ MetricExporterConfiguration.metricExporterSpiManager(
+ properties, OtlpGrpcConfigTest.class.getClassLoader())))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("Client key provided but certification chain is missing");
assertThatThrownBy(
() ->
- LogRecordExporterConfiguration.configureOtlpLogs(properties, MeterProvider.noop()))
+ LogRecordExporterConfiguration.configureExporter(
+ "otlp",
+ LogRecordExporterConfiguration.logRecordExporterSpiManager(
+ properties, OtlpGrpcConfigTest.class.getClassLoader())))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("Client key provided but certification chain is missing");
}
@@ -303,17 +336,27 @@ void configureTlsMissingClientKeyPath() {
assertThatThrownBy(
() ->
SpanExporterConfiguration.configureExporter(
- "otlp", properties, NamedSpiManager.createEmpty(), MeterProvider.noop()))
+ "otlp",
+ SpanExporterConfiguration.spanExporterSpiManager(
+ properties, OtlpGrpcConfigTest.class.getClassLoader())))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("Client key chain provided but key is missing");
- assertThatThrownBy(() -> MetricExporterConfiguration.configureOtlpMetrics(properties))
+ assertThatThrownBy(
+ () ->
+ MetricExporterConfiguration.configureExporter(
+ "otlp",
+ MetricExporterConfiguration.metricExporterSpiManager(
+ properties, OtlpGrpcConfigTest.class.getClassLoader())))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("Client key chain provided but key is missing");
assertThatThrownBy(
() ->
- LogRecordExporterConfiguration.configureOtlpLogs(properties, MeterProvider.noop()))
+ LogRecordExporterConfiguration.configureExporter(
+ "otlp",
+ LogRecordExporterConfiguration.logRecordExporterSpiManager(
+ properties, OtlpGrpcConfigTest.class.getClassLoader())))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("Client key chain provided but key is missing");
}
diff --git a/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcRetryTest.java b/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcRetryTest.java
index 731bf9a4a13..31ef7c1c0a1 100644
--- a/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcRetryTest.java
+++ b/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpGrpcRetryTest.java
@@ -13,11 +13,11 @@
import com.google.common.collect.Lists;
import com.linecorp.armeria.testing.junit5.server.SelfSignedCertificateExtension;
import io.grpc.Status;
-import io.opentelemetry.api.metrics.MeterProvider;
import io.opentelemetry.exporter.internal.grpc.OkHttpGrpcExporter;
import io.opentelemetry.exporter.internal.retry.RetryPolicy;
import io.opentelemetry.exporter.internal.retry.RetryUtil;
import io.opentelemetry.internal.testing.slf4j.SuppressLogger;
+import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
import io.opentelemetry.sdk.common.CompletableResultCode;
import io.opentelemetry.sdk.logs.data.LogRecordData;
@@ -60,12 +60,12 @@ void configureSpanExporterRetryPolicy() {
props.put(
"otel.exporter.otlp.traces.certificate", certificate.certificateFile().getAbsolutePath());
props.put("otel.experimental.exporter.otlp.retry.enabled", "true");
+ ConfigProperties properties = DefaultConfigProperties.createForTest(props);
try (SpanExporter spanExporter =
SpanExporterConfiguration.configureExporter(
"otlp",
- DefaultConfigProperties.createForTest(props),
- NamedSpiManager.createEmpty(),
- MeterProvider.noop())) {
+ SpanExporterConfiguration.spanExporterSpiManager(
+ properties, OtlpGrpcRetryTest.class.getClassLoader()))) {
testRetryableStatusCodes(() -> SPAN_DATA, spanExporter::export, server.traceRequests::size);
testDefaultRetryPolicy(() -> SPAN_DATA, spanExporter::export, server.traceRequests::size);
@@ -81,8 +81,11 @@ void configureMetricExporterRetryPolicy() {
"otel.exporter.otlp.metrics.certificate", certificate.certificateFile().getAbsolutePath());
props.put("otel.experimental.exporter.otlp.retry.enabled", "true");
try (MetricExporter metricExporter =
- MetricExporterConfiguration.configureOtlpMetrics(
- DefaultConfigProperties.createForTest(props))) {
+ MetricExporterConfiguration.configureExporter(
+ "otlp",
+ MetricExporterConfiguration.metricExporterSpiManager(
+ DefaultConfigProperties.createForTest(props),
+ OtlpGrpcRetryTest.class.getClassLoader()))) {
testRetryableStatusCodes(
() -> METRIC_DATA, metricExporter::export, server.metricRequests::size);
@@ -100,8 +103,11 @@ void configureLogRecordExporterRetryPolicy() {
"otel.exporter.otlp.logs.certificate", certificate.certificateFile().getAbsolutePath());
props.put("otel.experimental.exporter.otlp.retry.enabled", "true");
try (LogRecordExporter logRecordExporter =
- LogRecordExporterConfiguration.configureOtlpLogs(
- DefaultConfigProperties.createForTest(props), MeterProvider.noop())) {
+ LogRecordExporterConfiguration.configureExporter(
+ "otlp",
+ LogRecordExporterConfiguration.logRecordExporterSpiManager(
+ DefaultConfigProperties.createForTest(props),
+ OtlpGrpcConfigTest.class.getClassLoader()))) {
testRetryableStatusCodes(
() -> LOG_RECORD_DATA, logRecordExporter::export, server.logRequests::size);
testDefaultRetryPolicy(
diff --git a/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpHttpConfigTest.java b/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpHttpConfigTest.java
index 109e384258f..801c5cc9709 100644
--- a/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpHttpConfigTest.java
+++ b/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpHttpConfigTest.java
@@ -17,7 +17,6 @@
import com.google.common.collect.Lists;
import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.api.logs.GlobalLoggerProvider;
-import io.opentelemetry.api.metrics.MeterProvider;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
@@ -70,10 +69,19 @@ void configureExportersGeneral() {
ConfigProperties properties = DefaultConfigProperties.createForTest(props);
SpanExporter spanExporter =
SpanExporterConfiguration.configureExporter(
- "otlp", properties, NamedSpiManager.createEmpty(), MeterProvider.noop());
- MetricExporter metricExporter = MetricExporterConfiguration.configureOtlpMetrics(properties);
+ "otlp",
+ SpanExporterConfiguration.spanExporterSpiManager(
+ properties, OtlpHttpConfigTest.class.getClassLoader()));
+ MetricExporter metricExporter =
+ MetricExporterConfiguration.configureExporter(
+ "otlp",
+ MetricExporterConfiguration.metricExporterSpiManager(
+ properties, OtlpHttpConfigTest.class.getClassLoader()));
LogRecordExporter logRecordExporter =
- LogRecordExporterConfiguration.configureOtlpLogs(properties, MeterProvider.noop());
+ LogRecordExporterConfiguration.configureExporter(
+ "otlp",
+ LogRecordExporterConfiguration.logRecordExporterSpiManager(
+ properties, OtlpHttpConfigTest.class.getClassLoader()));
assertThat(spanExporter)
.extracting("delegate.client", as(InstanceOfAssertFactories.type(OkHttpClient.class)))
@@ -151,12 +159,12 @@ void configureSpanExporter() {
props.put("otel.exporter.otlp.traces.headers", "header-key=header-value");
props.put("otel.exporter.otlp.traces.compression", "gzip");
props.put("otel.exporter.otlp.traces.timeout", "15s");
+ ConfigProperties properties = DefaultConfigProperties.createForTest(props);
SpanExporter spanExporter =
SpanExporterConfiguration.configureExporter(
"otlp",
- DefaultConfigProperties.createForTest(props),
- NamedSpiManager.createEmpty(),
- MeterProvider.noop());
+ SpanExporterConfiguration.spanExporterSpiManager(
+ properties, OtlpHttpConfigTest.class.getClassLoader()));
assertThat(spanExporter)
.extracting("delegate.client", as(InstanceOfAssertFactories.type(OkHttpClient.class)))
@@ -200,8 +208,11 @@ public void configureMetricExporter() {
props.put("otel.exporter.otlp.metrics.timeout", "15s");
props.put("otel.exporter.otlp.metrics.temporality.preference", "DELTA");
MetricExporter metricExporter =
- MetricExporterConfiguration.configureOtlpMetrics(
- DefaultConfigProperties.createForTest(props));
+ MetricExporterConfiguration.configureExporter(
+ "otlp",
+ MetricExporterConfiguration.metricExporterSpiManager(
+ DefaultConfigProperties.createForTest(props),
+ OtlpHttpConfigTest.class.getClassLoader()));
assertThat(metricExporter)
.extracting("delegate.client", as(InstanceOfAssertFactories.type(OkHttpClient.class)))
@@ -244,8 +255,11 @@ public void configureLogRecordExporter() {
props.put("otel.exporter.otlp.logs.compression", "gzip");
props.put("otel.exporter.otlp.logs.timeout", "15s");
LogRecordExporter logRecordExporter =
- LogRecordExporterConfiguration.configureOtlpLogs(
- DefaultConfigProperties.createForTest(props), MeterProvider.noop());
+ LogRecordExporterConfiguration.configureExporter(
+ "otlp",
+ LogRecordExporterConfiguration.logRecordExporterSpiManager(
+ DefaultConfigProperties.createForTest(props),
+ OtlpHttpConfigTest.class.getClassLoader()));
assertThat(logRecordExporter)
.extracting("delegate.client", as(InstanceOfAssertFactories.type(OkHttpClient.class)))
@@ -275,17 +289,27 @@ void configureTlsInvalidCertificatePath() {
assertThatThrownBy(
() ->
SpanExporterConfiguration.configureExporter(
- "otlp", properties, NamedSpiManager.createEmpty(), MeterProvider.noop()))
+ "otlp",
+ SpanExporterConfiguration.spanExporterSpiManager(
+ properties, OtlpHttpConfigTest.class.getClassLoader())))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("Invalid OTLP certificate/key path:");
- assertThatThrownBy(() -> MetricExporterConfiguration.configureOtlpMetrics(properties))
+ assertThatThrownBy(
+ () ->
+ MetricExporterConfiguration.configureExporter(
+ "otlp",
+ MetricExporterConfiguration.metricExporterSpiManager(
+ properties, OtlpHttpConfigTest.class.getClassLoader())))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("Invalid OTLP certificate/key path:");
assertThatThrownBy(
() ->
- LogRecordExporterConfiguration.configureOtlpLogs(properties, MeterProvider.noop()))
+ LogRecordExporterConfiguration.configureExporter(
+ "otlp",
+ LogRecordExporterConfiguration.logRecordExporterSpiManager(
+ properties, OtlpHttpConfigTest.class.getClassLoader())))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("Invalid OTLP certificate/key path:");
}
@@ -300,17 +324,27 @@ void configureTlsMissingClientCertificatePath() {
assertThatThrownBy(
() ->
SpanExporterConfiguration.configureExporter(
- "otlp", properties, NamedSpiManager.createEmpty(), MeterProvider.noop()))
+ "otlp",
+ SpanExporterConfiguration.spanExporterSpiManager(
+ properties, OtlpHttpConfigTest.class.getClassLoader())))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("Client key provided but certification chain is missing");
- assertThatThrownBy(() -> MetricExporterConfiguration.configureOtlpMetrics(properties))
+ assertThatThrownBy(
+ () ->
+ MetricExporterConfiguration.configureExporter(
+ "otlp",
+ MetricExporterConfiguration.metricExporterSpiManager(
+ properties, OtlpHttpConfigTest.class.getClassLoader())))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("Client key provided but certification chain is missing");
assertThatThrownBy(
() ->
- LogRecordExporterConfiguration.configureOtlpLogs(properties, MeterProvider.noop()))
+ LogRecordExporterConfiguration.configureExporter(
+ "otlp",
+ LogRecordExporterConfiguration.logRecordExporterSpiManager(
+ properties, OtlpHttpConfigTest.class.getClassLoader())))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("Client key provided but certification chain is missing");
}
@@ -325,17 +359,27 @@ void configureTlsMissingClientKeyPath() {
assertThatThrownBy(
() ->
SpanExporterConfiguration.configureExporter(
- "otlp", properties, NamedSpiManager.createEmpty(), MeterProvider.noop()))
+ "otlp",
+ SpanExporterConfiguration.spanExporterSpiManager(
+ properties, OtlpHttpConfigTest.class.getClassLoader())))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("Client key chain provided but key is missing");
- assertThatThrownBy(() -> MetricExporterConfiguration.configureOtlpMetrics(properties))
+ assertThatThrownBy(
+ () ->
+ MetricExporterConfiguration.configureExporter(
+ "otlp",
+ MetricExporterConfiguration.metricExporterSpiManager(
+ properties, OtlpHttpConfigTest.class.getClassLoader())))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("Client key chain provided but key is missing");
assertThatThrownBy(
() ->
- LogRecordExporterConfiguration.configureOtlpLogs(properties, MeterProvider.noop()))
+ LogRecordExporterConfiguration.configureExporter(
+ "otlp",
+ LogRecordExporterConfiguration.logRecordExporterSpiManager(
+ properties, OtlpHttpConfigTest.class.getClassLoader())))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining("Client key chain provided but key is missing");
}
diff --git a/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpHttpRetryTest.java b/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpHttpRetryTest.java
index 08a23a07af1..bf778816ba6 100644
--- a/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpHttpRetryTest.java
+++ b/sdk-extensions/autoconfigure/src/testOtlp/java/io/opentelemetry/sdk/autoconfigure/OtlpHttpRetryTest.java
@@ -13,12 +13,12 @@
import com.google.common.collect.Lists;
import com.linecorp.armeria.common.HttpResponse;
import com.linecorp.armeria.common.HttpStatus;
-import io.opentelemetry.api.metrics.MeterProvider;
import io.opentelemetry.exporter.internal.grpc.OkHttpGrpcExporter;
import io.opentelemetry.exporter.internal.okhttp.OkHttpExporter;
import io.opentelemetry.exporter.internal.retry.RetryPolicy;
import io.opentelemetry.exporter.internal.retry.RetryUtil;
import io.opentelemetry.internal.testing.slf4j.SuppressLogger;
+import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
import io.opentelemetry.sdk.common.CompletableResultCode;
import io.opentelemetry.sdk.logs.data.LogRecordData;
@@ -59,12 +59,12 @@ void configureSpanExporterRetryPolicy() {
"otel.exporter.otlp.traces.certificate",
server.selfSignedCertificate.certificate().getPath());
props.put("otel.experimental.exporter.otlp.retry.enabled", "true");
+ ConfigProperties properties = DefaultConfigProperties.createForTest(props);
try (SpanExporter spanExporter =
SpanExporterConfiguration.configureExporter(
"otlp",
- DefaultConfigProperties.createForTest(props),
- NamedSpiManager.createEmpty(),
- MeterProvider.noop())) {
+ SpanExporterConfiguration.spanExporterSpiManager(
+ properties, OtlpHttpRetryTest.class.getClassLoader()))) {
testRetryableStatusCodes(() -> SPAN_DATA, spanExporter::export, server.traceRequests::size);
testDefaultRetryPolicy(() -> SPAN_DATA, spanExporter::export, server.traceRequests::size);
@@ -84,8 +84,11 @@ void configureMetricExporterRetryPolicy() {
server.selfSignedCertificate.certificate().getPath());
props.put("otel.experimental.exporter.otlp.retry.enabled", "true");
try (MetricExporter metricExporter =
- MetricExporterConfiguration.configureOtlpMetrics(
- DefaultConfigProperties.createForTest(props))) {
+ MetricExporterConfiguration.configureExporter(
+ "otlp",
+ MetricExporterConfiguration.metricExporterSpiManager(
+ DefaultConfigProperties.createForTest(props),
+ OtlpHttpRetryTest.class.getClassLoader()))) {
testRetryableStatusCodes(
() -> METRIC_DATA, metricExporter::export, server.metricRequests::size);
@@ -106,8 +109,11 @@ void configureLogRecordExporterRetryPolicy() {
server.selfSignedCertificate.certificate().getPath());
props.put("otel.experimental.exporter.otlp.retry.enabled", "true");
try (LogRecordExporter logRecordExporter =
- LogRecordExporterConfiguration.configureOtlpLogs(
- DefaultConfigProperties.createForTest(props), MeterProvider.noop())) {
+ LogRecordExporterConfiguration.configureExporter(
+ "otlp",
+ LogRecordExporterConfiguration.logRecordExporterSpiManager(
+ DefaultConfigProperties.createForTest(props),
+ OtlpHttpRetryTest.class.getClassLoader()))) {
testRetryableStatusCodes(
() -> LOG_RECORD_DATA, logRecordExporter::export, server.logRequests::size);
testDefaultRetryPolicy(