diff --git a/exporters/logging-otlp/build.gradle.kts b/exporters/logging-otlp/build.gradle.kts
index 6dcb66aed88..4034af4a489 100644
--- a/exporters/logging-otlp/build.gradle.kts
+++ b/exporters/logging-otlp/build.gradle.kts
@@ -14,6 +14,7 @@ dependencies {
compileOnly(project(":sdk:logs"))
implementation(project(":exporters:otlp:common"))
+ implementation(project(":sdk-extensions:autoconfigure-spi"))
implementation("com.fasterxml.jackson.core:jackson-core")
diff --git a/exporters/logging-otlp/src/main/java/io/opentelemetry/exporter/logging/otlp/internal/LoggingLogRecordExporterProvider.java b/exporters/logging-otlp/src/main/java/io/opentelemetry/exporter/logging/otlp/internal/LoggingLogRecordExporterProvider.java
new file mode 100644
index 00000000000..ebb0d2d0865
--- /dev/null
+++ b/exporters/logging-otlp/src/main/java/io/opentelemetry/exporter/logging/otlp/internal/LoggingLogRecordExporterProvider.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package io.opentelemetry.exporter.logging.otlp.internal;
+
+import io.opentelemetry.exporter.logging.otlp.OtlpJsonLoggingLogRecordExporter;
+import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
+import io.opentelemetry.sdk.autoconfigure.spi.logs.ConfigurableLogRecordExporterProvider;
+import io.opentelemetry.sdk.logs.export.LogRecordExporter;
+
+/**
+ * {@link LogRecordExporter} SPI implementation for {@link OtlpJsonLoggingLogRecordExporter}.
+ *
+ *
This class is internal and is hence not for public use. Its APIs are unstable and can change
+ * at any time.
+ */
+public class LoggingLogRecordExporterProvider implements ConfigurableLogRecordExporterProvider {
+ @Override
+ public LogRecordExporter createExporter(ConfigProperties config) {
+ return OtlpJsonLoggingLogRecordExporter.create();
+ }
+
+ @Override
+ public String getName() {
+ return "logging-otlp";
+ }
+}
diff --git a/exporters/logging-otlp/src/main/java/io/opentelemetry/exporter/logging/otlp/internal/LoggingMetricExporterProvider.java b/exporters/logging-otlp/src/main/java/io/opentelemetry/exporter/logging/otlp/internal/LoggingMetricExporterProvider.java
new file mode 100644
index 00000000000..b5669b5426a
--- /dev/null
+++ b/exporters/logging-otlp/src/main/java/io/opentelemetry/exporter/logging/otlp/internal/LoggingMetricExporterProvider.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package io.opentelemetry.exporter.logging.otlp.internal;
+
+import io.opentelemetry.exporter.logging.otlp.OtlpJsonLoggingMetricExporter;
+import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
+import io.opentelemetry.sdk.autoconfigure.spi.metrics.ConfigurableMetricExporterProvider;
+import io.opentelemetry.sdk.metrics.export.MetricExporter;
+
+/**
+ * {@link MetricExporter} SPI implementation for {@link OtlpJsonLoggingMetricExporter}.
+ *
+ *
This class is internal and is hence not for public use. Its APIs are unstable and can change
+ * at any time.
+ */
+public class LoggingMetricExporterProvider implements ConfigurableMetricExporterProvider {
+ @Override
+ public MetricExporter createExporter(ConfigProperties config) {
+ return OtlpJsonLoggingMetricExporter.create();
+ }
+
+ @Override
+ public String getName() {
+ return "logging-otlp";
+ }
+}
diff --git a/exporters/logging-otlp/src/main/java/io/opentelemetry/exporter/logging/otlp/internal/LoggingSpanExporterProvider.java b/exporters/logging-otlp/src/main/java/io/opentelemetry/exporter/logging/otlp/internal/LoggingSpanExporterProvider.java
new file mode 100644
index 00000000000..6ce1856a894
--- /dev/null
+++ b/exporters/logging-otlp/src/main/java/io/opentelemetry/exporter/logging/otlp/internal/LoggingSpanExporterProvider.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package io.opentelemetry.exporter.logging.otlp.internal;
+
+import io.opentelemetry.exporter.logging.otlp.OtlpJsonLoggingSpanExporter;
+import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
+import io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider;
+import io.opentelemetry.sdk.trace.export.SpanExporter;
+
+/**
+ * {@link SpanExporter} SPI implementation for {@link OtlpJsonLoggingSpanExporter}.
+ *
+ *
This class is internal and is hence not for public use. Its APIs are unstable and can change
+ * at any time.
+ */
+public class LoggingSpanExporterProvider implements ConfigurableSpanExporterProvider {
+ @Override
+ public SpanExporter createExporter(ConfigProperties config) {
+ return OtlpJsonLoggingSpanExporter.create();
+ }
+
+ @Override
+ public String getName() {
+ return "logging-otlp";
+ }
+}
diff --git a/exporters/logging-otlp/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.logs.ConfigurableLogRecordExporterProvider b/exporters/logging-otlp/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.logs.ConfigurableLogRecordExporterProvider
new file mode 100644
index 00000000000..9119f54ef00
--- /dev/null
+++ b/exporters/logging-otlp/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.logs.ConfigurableLogRecordExporterProvider
@@ -0,0 +1 @@
+io.opentelemetry.exporter.logging.otlp.internal.LoggingLogRecordExporterProvider
diff --git a/exporters/logging-otlp/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.metrics.ConfigurableMetricExporterProvider b/exporters/logging-otlp/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.metrics.ConfigurableMetricExporterProvider
new file mode 100644
index 00000000000..2b532ca9a38
--- /dev/null
+++ b/exporters/logging-otlp/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.metrics.ConfigurableMetricExporterProvider
@@ -0,0 +1 @@
+io.opentelemetry.exporter.logging.otlp.internal.LoggingMetricExporterProvider
diff --git a/exporters/logging-otlp/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider b/exporters/logging-otlp/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider
new file mode 100644
index 00000000000..fe444f4acf3
--- /dev/null
+++ b/exporters/logging-otlp/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider
@@ -0,0 +1 @@
+io.opentelemetry.exporter.logging.otlp.internal.LoggingSpanExporterProvider
diff --git a/sdk-extensions/autoconfigure/build.gradle.kts b/sdk-extensions/autoconfigure/build.gradle.kts
index 7c1d6b827a3..cff9dc41f55 100644
--- a/sdk-extensions/autoconfigure/build.gradle.kts
+++ b/sdk-extensions/autoconfigure/build.gradle.kts
@@ -16,7 +16,6 @@ dependencies {
implementation(project(":exporters:common"))
compileOnly(project(":exporters:jaeger"))
- compileOnly(project(":exporters:logging-otlp"))
compileOnly(project(":exporters:otlp:all"))
compileOnly(project(":exporters:otlp:logs"))
compileOnly(project(":exporters:otlp:common"))
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 693aa3303f8..981ff3740d7 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
@@ -11,7 +11,6 @@
import io.opentelemetry.api.metrics.MeterProvider;
import io.opentelemetry.exporter.internal.retry.RetryUtil;
-import io.opentelemetry.exporter.logging.otlp.OtlpJsonLoggingLogRecordExporter;
import io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogRecordExporter;
import io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogRecordExporterBuilder;
import io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporter;
@@ -35,6 +34,7 @@ class LogRecordExporterConfiguration {
static {
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");
}
// Visible for test
@@ -60,12 +60,7 @@ static Map configureLogRecordExporters(
}
NamedSpiManager spiExportersManager =
- SpiUtil.loadConfigurable(
- ConfigurableLogRecordExporterProvider.class,
- ConfigurableLogRecordExporterProvider::getName,
- ConfigurableLogRecordExporterProvider::createExporter,
- config,
- serviceClassLoader);
+ logRecordExporterSpiManager(config, serviceClassLoader);
Map exportersByName = new HashMap<>();
for (String name : exporterNames) {
@@ -81,6 +76,17 @@ static Map configureLogRecordExporters(
return Collections.unmodifiableMap(exportersByName);
}
+ // Visible for testing
+ static NamedSpiManager logRecordExporterSpiManager(
+ ConfigProperties config, ClassLoader serviceClassLoader) {
+ return SpiUtil.loadConfigurable(
+ ConfigurableLogRecordExporterProvider.class,
+ ConfigurableLogRecordExporterProvider::getName,
+ ConfigurableLogRecordExporterProvider::createExporter,
+ config,
+ serviceClassLoader);
+ }
+
// Visible for testing
@Nullable
static LogRecordExporter configureExporter(
@@ -91,12 +97,6 @@ static LogRecordExporter configureExporter(
switch (name) {
case "otlp":
return configureOtlpLogs(config, meterProvider);
- case "logging-otlp":
- ClasspathUtil.checkClassExists(
- "io.opentelemetry.exporter.logging.otlp.OtlpJsonLoggingLogRecordExporter",
- "OTLP JSON Logging Log Exporter",
- "opentelemetry-exporter-logging-otlp");
- return OtlpJsonLoggingLogRecordExporter.create();
default:
LogRecordExporter spiExporter = spiExportersManager.getByName(name);
if (spiExporter == null) {
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 a82cc6c5cb1..11d9d45061d 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
@@ -10,7 +10,6 @@
import static io.opentelemetry.sdk.autoconfigure.OtlpConfigUtil.PROTOCOL_HTTP_PROTOBUF;
import io.opentelemetry.exporter.internal.retry.RetryUtil;
-import io.opentelemetry.exporter.logging.otlp.OtlpJsonLoggingMetricExporter;
import io.opentelemetry.exporter.otlp.http.metrics.OtlpHttpMetricExporter;
import io.opentelemetry.exporter.otlp.http.metrics.OtlpHttpMetricExporterBuilder;
import io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporter;
@@ -37,6 +36,7 @@ final class MetricExporterConfiguration {
static {
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");
}
static MetricReader configureExporter(
@@ -54,9 +54,6 @@ static MetricReader configureExporter(
case "otlp":
metricExporter = configureOtlpMetrics(config);
break;
- case "logging-otlp":
- metricExporter = configureLoggingOtlpExporter();
- break;
default:
MetricExporter spiExporter = configureSpiExporter(name, config, serviceClassLoader);
if (spiExporter == null) {
@@ -78,14 +75,6 @@ static MetricReader configureExporter(
return configurePeriodicMetricReader(config, metricExporter);
}
- private static MetricExporter configureLoggingOtlpExporter() {
- ClasspathUtil.checkClassExists(
- "io.opentelemetry.exporter.logging.otlp.OtlpJsonLoggingMetricExporter",
- "OTLP JSON Logging Metrics Exporter",
- "opentelemetry-exporter-logging-otlp");
- return OtlpJsonLoggingMetricExporter.create();
- }
-
// Visible for testing.
@Nullable
static MetricExporter configureSpiExporter(
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 380cc3c5eaf..f57dfe475d4 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
@@ -14,7 +14,6 @@
import io.opentelemetry.exporter.internal.retry.RetryUtil;
import io.opentelemetry.exporter.jaeger.JaegerGrpcSpanExporter;
import io.opentelemetry.exporter.jaeger.JaegerGrpcSpanExporterBuilder;
-import io.opentelemetry.exporter.logging.otlp.OtlpJsonLoggingSpanExporter;
import io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporter;
import io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporterBuilder;
import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter;
@@ -41,6 +40,7 @@ final class SpanExporterConfiguration {
static {
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");
}
// Visible for testing
@@ -69,12 +69,7 @@ static Map configureSpanExporters(
}
NamedSpiManager spiExportersManager =
- SpiUtil.loadConfigurable(
- ConfigurableSpanExporterProvider.class,
- ConfigurableSpanExporterProvider::getName,
- ConfigurableSpanExporterProvider::createExporter,
- config,
- serviceClassLoader);
+ spanExporterSpiManager(config, serviceClassLoader);
return exporterNames.stream()
.collect(
@@ -86,6 +81,17 @@ static Map configureSpanExporters(
config)));
}
+ // Visible for testing
+ static NamedSpiManager spanExporterSpiManager(
+ ConfigProperties config, ClassLoader serviceClassLoader) {
+ return SpiUtil.loadConfigurable(
+ ConfigurableSpanExporterProvider.class,
+ ConfigurableSpanExporterProvider::getName,
+ ConfigurableSpanExporterProvider::createExporter,
+ config,
+ serviceClassLoader);
+ }
+
// Visible for testing
static SpanExporter configureExporter(
String name,
@@ -99,12 +105,6 @@ static SpanExporter configureExporter(
return configureJaeger(config, meterProvider);
case "zipkin":
return configureZipkin(config);
- case "logging-otlp":
- ClasspathUtil.checkClassExists(
- "io.opentelemetry.exporter.logging.otlp.OtlpJsonLoggingSpanExporter",
- "OTLP JSON Logging Trace Exporter",
- "opentelemetry-exporter-logging-otlp");
- return OtlpJsonLoggingSpanExporter.create();
default:
SpanExporter spiExporter = spiExportersManager.getByName(name);
if (spiExporter == null) {
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 06d971c8fc6..24a50fd869e 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
@@ -86,11 +86,16 @@ void loggingSpansOtlp() {
assertThatThrownBy(
() ->
SpanExporterConfiguration.configureExporter(
- "logging-otlp", EMPTY, NamedSpiManager.createEmpty(), MeterProvider.noop()))
+ "logging-otlp",
+ EMPTY,
+ SpanExporterConfiguration.spanExporterSpiManager(
+ DefaultConfigProperties.createForTest(Collections.emptyMap()),
+ NotOnClasspathTest.class.getClassLoader()),
+ MeterProvider.noop()))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining(
- "OTLP JSON Logging Trace Exporter enabled but opentelemetry-exporter-logging-otlp not found on "
- + "classpath");
+ "otel.traces.exporter set to \"logging-otlp\" but opentelemetry-exporter-logging-otlp not found on classpath."
+ + " Make sure to add it as a dependency.");
}
@Test
@@ -119,8 +124,8 @@ void loggingMetricsOtlp() {
(a, unused) -> a))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining(
- "OTLP JSON Logging Metrics Exporter enabled but opentelemetry-exporter-logging-otlp not found on "
- + "classpath");
+ "otel.metrics.exporter set to \"logging-otlp\" but opentelemetry-exporter-logging-otlp not found on classpath."
+ + " Make sure to add it as a dependency.");
}
@Test
@@ -140,11 +145,16 @@ void loggingLogsOtlp() {
assertThatThrownBy(
() ->
LogRecordExporterConfiguration.configureExporter(
- "logging-otlp", EMPTY, NamedSpiManager.createEmpty(), MeterProvider.noop()))
+ "logging-otlp",
+ EMPTY,
+ LogRecordExporterConfiguration.logRecordExporterSpiManager(
+ DefaultConfigProperties.createForTest(Collections.emptyMap()),
+ NotOnClasspathTest.class.getClassLoader()),
+ MeterProvider.noop()))
.isInstanceOf(ConfigurationException.class)
.hasMessageContaining(
- "OTLP JSON Logging Log Exporter enabled but opentelemetry-exporter-logging-otlp not found on "
- + "classpath");
+ "otel.logs.exporter set to \"logging-otlp\" but opentelemetry-exporter-logging-otlp not found on classpath."
+ + " Make sure to add it as a dependency.");
}
@Test