From aace841f04bc8eec4a90823ff42e6e3c349b7264 Mon Sep 17 00:00:00 2001 From: Jean Bisutti Date: Mon, 24 Jun 2024 14:38:41 +0200 Subject: [PATCH] Use more @ConditionalOnEnabledInstrumentation --- .../mongo/MongoClientInstrumentationAutoConfiguration.java | 7 ++----- .../r2dbc/R2dbcInstrumentationAutoConfiguration.java | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/instrumentation/mongo/MongoClientInstrumentationAutoConfiguration.java b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/instrumentation/mongo/MongoClientInstrumentationAutoConfiguration.java index 279a01524cee..0eee74e37965 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/instrumentation/mongo/MongoClientInstrumentationAutoConfiguration.java +++ b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/instrumentation/mongo/MongoClientInstrumentationAutoConfiguration.java @@ -8,21 +8,18 @@ import com.mongodb.MongoClientSettings; import io.opentelemetry.api.OpenTelemetry; import io.opentelemetry.instrumentation.mongo.v3_1.MongoTelemetry; +import io.opentelemetry.instrumentation.spring.autoconfigure.internal.ConditionalOnEnabledInstrumentation; import io.opentelemetry.instrumentation.spring.autoconfigure.internal.InstrumentationConfigUtil; -import io.opentelemetry.instrumentation.spring.autoconfigure.internal.SdkEnabled; import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.mongo.MongoClientSettingsBuilderCustomizer; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; @ConditionalOnBean(OpenTelemetry.class) @ConditionalOnClass(MongoClientSettings.class) -@ConditionalOnProperty(name = "otel.instrumentation.mongo.enabled", matchIfMissing = true) -@Conditional(SdkEnabled.class) +@ConditionalOnEnabledInstrumentation(module = "mongo") @Configuration public class MongoClientInstrumentationAutoConfiguration { diff --git a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/instrumentation/r2dbc/R2dbcInstrumentationAutoConfiguration.java b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/instrumentation/r2dbc/R2dbcInstrumentationAutoConfiguration.java index dd3d88e41ab6..5c9a3b62665a 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/instrumentation/r2dbc/R2dbcInstrumentationAutoConfiguration.java +++ b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/instrumentation/r2dbc/R2dbcInstrumentationAutoConfiguration.java @@ -6,21 +6,18 @@ package io.opentelemetry.instrumentation.spring.autoconfigure.instrumentation.r2dbc; import io.opentelemetry.api.OpenTelemetry; -import io.opentelemetry.instrumentation.spring.autoconfigure.internal.SdkEnabled; +import io.opentelemetry.instrumentation.spring.autoconfigure.internal.ConditionalOnEnabledInstrumentation; import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; import io.r2dbc.spi.ConnectionFactory; import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; @ConditionalOnBean(OpenTelemetry.class) @ConditionalOnClass(ConnectionFactory.class) -@ConditionalOnProperty(name = "otel.instrumentation.r2dbc.enabled", matchIfMissing = true) -@Conditional(SdkEnabled.class) +@ConditionalOnEnabledInstrumentation(module = "r2dbc") @Configuration(proxyBeanMethods = false) public class R2dbcInstrumentationAutoConfiguration {