Clean up spring-boot-autoconfigure exporter logic
MODIFY
instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/logging/LoggingExporterProperties.java
instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/logging/LoggingExporterProperties.java
@@ -14,7 +14,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties(prefix = "otel.exporter.logging")
public final class LoggingExporterProperties {
- private boolean enabled = true;
+ private boolean enabled = false;
private final SignalProperties traces = new SignalProperties();
private final SignalProperties metrics = new SignalProperties();
@@ -36,7 +36,7 @@ public final class LoggingExporterProperties {
public static class SignalProperties {
- private boolean enabled = true;
+ private boolean enabled = false;
public boolean isEnabled() {
return enabled;

MODIFY
instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/logging/LoggingMetricExporterAutoConfiguration.java
instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/logging/LoggingMetricExporterAutoConfiguration.java
@@ -9,27 +9,37 @@ import io.opentelemetry.exporter.logging.LoggingMetricExporter;
import io.opentelemetry.exporter.logging.LoggingSpanExporter;
import io.opentelemetry.instrumentation.spring.autoconfigure.OpenTelemetryAutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
+import org.springframework.boot.autoconfigure.condition.AnyNestedCondition;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
/** Configures {@link LoggingSpanExporter} bean for tracing. */
@Configuration
@EnableConfigurationProperties(LoggingExporterProperties.class)
@AutoConfigureBefore(OpenTelemetryAutoConfiguration.class)
-@ConditionalOnProperty(
- prefix = "otel.exporter.logging",
- name = {"enabled", "metrics.enabled"},
- matchIfMissing = true)
+@Conditional(LoggingMetricExporterAutoConfiguration.AnyPropertyEnabled.class)
@ConditionalOnClass(LoggingMetricExporter.class)
public class LoggingMetricExporterAutoConfiguration {
@Bean
- @ConditionalOnMissingBean
public LoggingMetricExporter otelLoggingMetricExporter() {
return LoggingMetricExporter.create();
}
+
+ static final class AnyPropertyEnabled extends AnyNestedCondition {
+
+ AnyPropertyEnabled() {
+ super(ConfigurationPhase.PARSE_CONFIGURATION);
+ }
+
+ @ConditionalOnProperty("otel.exporter.logging.enabled")
+ static class LoggingEnabled {}
+
+ @ConditionalOnProperty("otel.exporter.logging.metrics.enabled")
+ static class LoggingMetricsEnabled {}
+ }
}

MODIFY
instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/logging/LoggingSpanExporterAutoConfiguration.java
instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/logging/LoggingSpanExporterAutoConfiguration.java
@@ -8,21 +8,20 @@ package io.opentelemetry.instrumentation.spring.autoconfigure.exporters.logging;
import io.opentelemetry.exporter.logging.LoggingSpanExporter;
import io.opentelemetry.instrumentation.spring.autoconfigure.OpenTelemetryAutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
+import org.springframework.boot.autoconfigure.condition.AnyNestedCondition;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
/** Configures {@link LoggingSpanExporter} bean for tracing. */
@Configuration
@EnableConfigurationProperties(LoggingExporterProperties.class)
@AutoConfigureBefore(OpenTelemetryAutoConfiguration.class)
-@ConditionalOnProperty(
- prefix = "otel.exporter.logging",
- name = {"enabled", "traces.enabled"},
- matchIfMissing = true)
+@Conditional(LoggingSpanExporterAutoConfiguration.AnyPropertyEnabled.class)
@ConditionalOnClass(LoggingSpanExporter.class)
public class LoggingSpanExporterAutoConfiguration {
@@ -31,4 +30,17 @@ public class LoggingSpanExporterAutoConfiguration {
public LoggingSpanExporter otelLoggingSpanExporter() {
return LoggingSpanExporter.create();
}
+
+ static final class AnyPropertyEnabled extends AnyNestedCondition {
+
+ AnyPropertyEnabled() {
+ super(ConfigurationPhase.PARSE_CONFIGURATION);
+ }
+
+ @ConditionalOnProperty("otel.exporter.logging.enabled")
+ static class LoggingEnabled {}
+
+ @ConditionalOnProperty("otel.exporter.logging.traces.enabled")
+ static class LoggingTracesEnabled {}
+ }
}

ADD
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/MetricExporterAutoConfigurationTest.java
+/*
+ * Copyright The OpenTelemetry Authors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package io.opentelemetry.instrumentation.spring.autoconfigure.exporters;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import io.opentelemetry.exporter.logging.LoggingMetricExporter;
+import io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporter;
+import io.opentelemetry.instrumentation.spring.autoconfigure.exporters.logging.LoggingMetricExporterAutoConfiguration;
+import io.opentelemetry.instrumentation.spring.autoconfigure.exporters.otlp.OtlpMetricExporterAutoConfiguration;
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.autoconfigure.AutoConfigurations;
+import org.springframework.boot.test.context.runner.ApplicationContextRunner;
+
+class MetricExporterAutoConfigurationTest {
+
+ private final ApplicationContextRunner contextRunner =
+ new ApplicationContextRunner()
+ .withConfiguration(
+ AutoConfigurations.of(
+ OtlpMetricExporterAutoConfiguration.class,
+ LoggingMetricExporterAutoConfiguration.class));
+
+ @Test
+ void defaultConfiguration() {
+ contextRunner.run(
+ context -> {
+ assertThat(context.getBean("otelOtlpGrpcMetricExporter", OtlpGrpcMetricExporter.class))
+ .as("OTLP exporter is enabled by default")
+ .isNotNull();
+ assertThat(context.containsBean("otelLoggingMetricExporter"))
+ .as("Logging exporter is not created unless explicitly configured")
+ .isFalse();
+ });
+ }
+
+ @Test
+ void loggingEnabledByConfiguration() {
+ contextRunner
+ .withPropertyValues("otel.exporter.logging.enabled=true")
+ .run(
+ context -> {
+ assertThat(
+ context.getBean("otelOtlpGrpcMetricExporter", OtlpGrpcMetricExporter.class))
+ .as("OTLP exporter is present even with logging enabled")
+ .isNotNull();
+ assertThat(context.getBean("otelLoggingMetricExporter", LoggingMetricExporter.class))
+ .as("Logging exporter is explicitly enabled")
+ .isNotNull();
+ });
+ }
+}

ADD
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/SpanExporterAutoConfigurationTest.java
+/*
+ * Copyright The OpenTelemetry Authors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package io.opentelemetry.instrumentation.spring.autoconfigure.exporters;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import io.opentelemetry.exporter.logging.LoggingSpanExporter;
+import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter;
+import io.opentelemetry.instrumentation.spring.autoconfigure.exporters.logging.LoggingSpanExporterAutoConfiguration;
+import io.opentelemetry.instrumentation.spring.autoconfigure.exporters.otlp.OtlpSpanExporterAutoConfiguration;
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.autoconfigure.AutoConfigurations;
+import org.springframework.boot.test.context.runner.ApplicationContextRunner;
+
+class SpanExporterAutoConfigurationTest {
+
+ private final ApplicationContextRunner contextRunner =
+ new ApplicationContextRunner()
+ .withConfiguration(
+ AutoConfigurations.of(
+ OtlpSpanExporterAutoConfiguration.class,
+ LoggingSpanExporterAutoConfiguration.class));
+
+ @Test
+ void defaultConfiguration() {
+ contextRunner.run(
+ context -> {
+ assertThat(context.getBean("otelOtlpGrpcSpanExporter", OtlpGrpcSpanExporter.class))
+ .as("OTLP exporter is enabled by default")
+ .isNotNull();
+ assertThat(context.containsBean("otelLoggingSpanExporter"))
+ .as("Logging exporter is not created unless explicitly configured")
+ .isFalse();
+ });
+ }
+
+ @Test
+ void loggingEnabledByConfiguration() {
+ contextRunner
+ .withPropertyValues("otel.exporter.logging.enabled=true")
+ .run(
+ context -> {
+ assertThat(context.getBean("otelOtlpGrpcSpanExporter", OtlpGrpcSpanExporter.class))
+ .as("OTLP exporter is present even with logging enabled")
+ .isNotNull();
+ assertThat(context.getBean("otelLoggingSpanExporter", LoggingSpanExporter.class))
+ .as("Logging exporter is explicitly enabled")
+ .isNotNull();
+ });
+ }
+}

RENAME
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/JaegerSpanExporterAutoConfigurationTest.java
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/jaeger/JaegerSpanExporterAutoConfigurationTest.java
* SPDX-License-Identifier: Apache-2.0
*/
-package io.opentelemetry.instrumentation.spring.autoconfigure.exporters;
+package io.opentelemetry.instrumentation.spring.autoconfigure.exporters.jaeger;
import static org.assertj.core.api.Assertions.assertThat;
import io.opentelemetry.exporter.jaeger.JaegerGrpcSpanExporter;
import io.opentelemetry.instrumentation.spring.autoconfigure.OpenTelemetryAutoConfiguration;
-import io.opentelemetry.instrumentation.spring.autoconfigure.exporters.jaeger.JaegerSpanExporterAutoConfiguration;
-import io.opentelemetry.instrumentation.spring.autoconfigure.exporters.jaeger.JaegerSpanExporterProperties;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;

MODIFY
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/logging/LoggingMetricExporterAutoConfigurationTest.java
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/logging/LoggingMetricExporterAutoConfigurationTest.java
@@ -60,9 +60,6 @@ class LoggingMetricExporterAutoConfigurationTest {
@Test
void noProperties() {
- runner.run(
- context ->
- assertThat(context.getBean("otelLoggingMetricExporter", LoggingMetricExporter.class))
- .isNotNull());
+ runner.run(context -> assertThat(context.containsBean("otelLoggingMetricExporter")).isFalse());
}
}

MODIFY
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/logging/LoggingSpanExporterAutoConfigurationTest.java
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/logging/LoggingSpanExporterAutoConfigurationTest.java
@@ -27,7 +27,7 @@ class LoggingSpanExporterAutoConfigurationTest {
@Test
@DisplayName("when exporters are ENABLED should initialize LoggingSpanExporter bean")
void loggingEnabled() {
- this.contextRunner
+ contextRunner
.withPropertyValues("otel.exporter.logging.enabled=true")
.run(
context ->
@@ -37,7 +37,7 @@ class LoggingSpanExporterAutoConfigurationTest {
@Test
void loggingTracesEnabled() {
- this.contextRunner
+ contextRunner
.withPropertyValues("otel.exporter.logging.traces.enabled=true")
.run(
context ->
@@ -48,7 +48,7 @@ class LoggingSpanExporterAutoConfigurationTest {
@Test
@DisplayName("when exporters are DISABLED should NOT initialize LoggingSpanExporter bean")
void loggingDisabled() {
- this.contextRunner
+ contextRunner
.withPropertyValues("otel.exporter.logging.enabled=false")
.run(context -> assertThat(context.containsBean("otelLoggingSpanExporter")).isFalse());
}
@@ -56,7 +56,7 @@ class LoggingSpanExporterAutoConfigurationTest {
@Test
@DisplayName("when exporters are DISABLED should NOT initialize LoggingSpanExporter bean")
void loggingTracesDisabled() {
- this.contextRunner
+ contextRunner
.withPropertyValues("otel.exporter.logging.traces.enabled=false")
.run(context -> assertThat(context.containsBean("otelLoggingSpanExporter")).isFalse());
}
@@ -65,9 +65,7 @@ class LoggingSpanExporterAutoConfigurationTest {
@DisplayName(
"when exporter enabled property is MISSING should initialize LoggingSpanExporter bean")
void exporterPresentByDefault() {
- this.contextRunner.run(
- context ->
- assertThat(context.getBean("otelLoggingSpanExporter", LoggingSpanExporter.class))
- .isNotNull());
+ contextRunner.run(
+ context -> assertThat(context.containsBean("otelLoggingSpanExporter")).isFalse());
}
}

RENAME
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/ZipkinSpanExporterAutoConfigurationTest.java
instrumentation/spring/spring-boot-autoconfigure/src/test/java/io/opentelemetry/instrumentation/spring/autoconfigure/exporters/zipkin/ZipkinSpanExporterAutoConfigurationTest.java
* SPDX-License-Identifier: Apache-2.0
*/
-package io.opentelemetry.instrumentation.spring.autoconfigure.exporters;
+package io.opentelemetry.instrumentation.spring.autoconfigure.exporters.zipkin;
import static org.assertj.core.api.Assertions.assertThat;
import io.opentelemetry.exporter.zipkin.ZipkinSpanExporter;
import io.opentelemetry.instrumentation.spring.autoconfigure.OpenTelemetryAutoConfiguration;
-import io.opentelemetry.instrumentation.spring.autoconfigure.exporters.zipkin.ZipkinSpanExporterAutoConfiguration;
-import io.opentelemetry.instrumentation.spring.autoconfigure.exporters.zipkin.ZipkinSpanExporterProperties;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;

DELETE
instrumentation/spring/starters/otlp-exporter-starter/README.md
-# OpenTelemetry OTLP Exporter Starter
-
-OpenTelemetry OTLP Exporter Starter is a starter package that includes the opentelemetry-api, opentelemetry-sdk, opentelemetry-extension-annotations, opentelmetry-logging-exporter, opentelemetry-spring-boot-autoconfigurations and spring framework starters required to setup distributed tracing. It also provides the [opentelemetry-exporters-otlp](https://github.com/open-telemetry/opentelemetry-java/tree/main/exporters/otlp) artifact and corresponding exporter auto-configuration. Check out [opentelemetry-spring-boot-autoconfigure](../../spring-boot-autoconfigure/README.md#features) for the list of supported libraries and features.
-
-## Quickstart
-
-### Add these dependencies to your project.
-
-Replace `OPENTELEMETRY_VERSION` with the latest stable [release](https://search.maven.org/search?q=g:io.opentelemetry).
- - Minimum version: `1.1.0`
-
-
-#### Maven
-
-```xml
-<dependencies>
-
- <dependency>
- <groupId>io.opentelemetry.instrumentation</groupId>
- <artifactId>opentelemetry-otlp-exporter-starter</artifactId>
- <version>OPENTELEMETRY_VERSION</version>
- </dependency>
-
-</dependencies>
-```
-
-#### Gradle
-
-```groovy
-implementation("io.opentelemetry.instrumentation:opentelemetry-otlp-exporter-starter:OPENTELEMETRY_VERSION")
-```
-
-### Starter Guide
-
-Check out [OpenTelemetry Manual Instrumentation](https://opentelemetry.io/docs/instrumentation/java/manual/) to learn more about
-using the OpenTelemetry API to instrument your code.

DELETE
instrumentation/spring/starters/otlp-exporter-starter/build.gradle.kts
-plugins {
- id("otel.java-conventions")
- id("otel.publish-conventions")
-}
-
-group = "io.opentelemetry.instrumentation"
-
-val versions: Map<String, String> by project
-
-dependencies {
- api("org.springframework.boot:spring-boot-starter:${versions["org.springframework.boot"]}")
- api(project(":instrumentation:spring:starters:spring-starter"))
- api("io.opentelemetry:opentelemetry-exporter-otlp")
-}

MODIFY
instrumentation/spring/starters/spring-starter/build.gradle.kts
instrumentation/spring/starters/spring-starter/build.gradle.kts
@@ -14,6 +14,7 @@ dependencies {
api("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi")
api("io.opentelemetry:opentelemetry-api")
api("io.opentelemetry:opentelemetry-exporter-logging")
+ api("io.opentelemetry:opentelemetry-exporter-otlp")
api("io.opentelemetry:opentelemetry-sdk")
api(project(":instrumentation-annotations"))
}

MODIFY
settings.gradle.kts
settings.gradle.kts
@@ -447,7 +447,6 @@ include(":instrumentation:spring:spring-ws-2.0:javaagent")
include(":instrumentation:spring:spring-boot-autoconfigure")
include(":instrumentation:spring:starters:spring-starter")
include(":instrumentation:spring:starters:jaeger-exporter-starter")
-include(":instrumentation:spring:starters:otlp-exporter-starter")
include(":instrumentation:spring:starters:zipkin-exporter-starter")
include(":instrumentation:spymemcached-2.12:javaagent")
include(":instrumentation:struts-2.3:javaagent")

Clean up spring-boot-autoconfigure exporter logic (#6374)