From c9f3a38de1e193e8103f717000b0f850e6f26b2c Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Fri, 15 Mar 2024 13:56:30 +0100 Subject: [PATCH] Adjust toggle names in OTel InstrumentBuildTimeConfig This is to be consistent with the new extension names. --- .../InstrumentationProcessor.java | 8 ++-- .../build/InstrumentBuildTimeConfig.java | 14 +++---- ...ConfigFallbackConfigSourceInterceptor.java | 40 +++++++++++++++++++ ...ConfigRelocateConfigSourceInterceptor.java | 40 +++++++++++++++++++ ...io.smallrye.config.ConfigSourceInterceptor | 2 + 5 files changed, 93 insertions(+), 11 deletions(-) create mode 100644 extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/build/InstrumentBuildTimeConfigFallbackConfigSourceInterceptor.java create mode 100644 extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/build/InstrumentBuildTimeConfigRelocateConfigSourceInterceptor.java diff --git a/extensions/opentelemetry/deployment/src/main/java/io/quarkus/opentelemetry/deployment/tracing/instrumentation/InstrumentationProcessor.java b/extensions/opentelemetry/deployment/src/main/java/io/quarkus/opentelemetry/deployment/tracing/instrumentation/InstrumentationProcessor.java index 3c6103be30b90..c7b2970acbb89 100644 --- a/extensions/opentelemetry/deployment/src/main/java/io/quarkus/opentelemetry/deployment/tracing/instrumentation/InstrumentationProcessor.java +++ b/extensions/opentelemetry/deployment/src/main/java/io/quarkus/opentelemetry/deployment/tracing/instrumentation/InstrumentationProcessor.java @@ -85,7 +85,7 @@ void registerRestClientClassicProvider( BuildProducer additionalBeans, OTelBuildConfig config) { if (capabilities.isPresent(Capability.REST_CLIENT) && capabilities.isMissing(Capability.REST_CLIENT_REACTIVE) - && config.instrument().restClientClassic()) { + && config.instrument().resteasyClient()) { additionalIndexed.produce(new AdditionalIndexedClassesBuildItem(OpenTelemetryClientFilter.class.getName())); additionalBeans.produce(new AdditionalBeanBuildItem(OpenTelemetryClientFilter.class)); } @@ -96,7 +96,7 @@ void registerReactiveMessagingMessageDecorator( Capabilities capabilities, BuildProducer additionalBeans, OTelBuildConfig config) { - if (capabilities.isPresent(Capability.SMALLRYE_REACTIVE_MESSAGING) && config.instrument().reactiveMessaging()) { + if (capabilities.isPresent(Capability.MESSAGING) && config.instrument().messaging()) { additionalBeans.produce(new AdditionalBeanBuildItem(ReactiveMessagingTracingOutgoingDecorator.class)); additionalBeans.produce(new AdditionalBeanBuildItem(ReactiveMessagingTracingIncomingDecorator.class)); } @@ -122,7 +122,7 @@ VertxOptionsConsumerBuildItem vertxTracingOptions( void registerResteasyClassicAndOrResteasyReactiveProvider(OTelBuildConfig config, Capabilities capabilities, BuildProducer resteasyJaxrsProviderBuildItemBuildProducer) { - if (capabilities.isPresent(Capability.RESTEASY) && config.instrument().resteasyClassic()) { + if (capabilities.isPresent(Capability.RESTEASY) && config.instrument().resteasy()) { resteasyJaxrsProviderBuildItemBuildProducer .produce(new ResteasyJaxrsProviderBuildItem(OpenTelemetryClassicServerFilter.class.getName())); } @@ -134,7 +134,7 @@ void resteasyReactiveIntegration( BuildProducer containerRequestFilterBuildItemBuildProducer, BuildProducer preExceptionMapperHandlerBuildItemBuildProducer, OTelBuildConfig config) { - if (capabilities.isPresent(Capability.RESTEASY_REACTIVE) && config.instrument().resteasyReactive()) { + if (capabilities.isPresent(Capability.RESTEASY_REACTIVE) && config.instrument().rest()) { containerRequestFilterBuildItemBuildProducer .produce(new CustomContainerRequestFilterBuildItem(OpenTelemetryReactiveServerFilter.class.getName())); preExceptionMapperHandlerBuildItemBuildProducer diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/build/InstrumentBuildTimeConfig.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/build/InstrumentBuildTimeConfig.java index 09ecb1532018b..74bac7260def3 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/build/InstrumentBuildTimeConfig.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/build/InstrumentBuildTimeConfig.java @@ -13,28 +13,28 @@ public interface InstrumentBuildTimeConfig { boolean grpc(); /** - * Enables instrumentation for SmallRye Reactive Messaging. + * Enables instrumentation for Messaging. */ @WithDefault("true") - boolean reactiveMessaging(); + boolean messaging(); /** - * Enables instrumentation for JAX-RS Rest Client backed by RESTEasy Classic. + * Enables instrumentation for REST Client backed by RESTEasy Classic. */ @WithDefault("true") - boolean restClientClassic(); + boolean resteasyClient(); /** - * Enables instrumentation for RESTEasy Reactive. + * Enables instrumentation for Quarkus REST. */ @WithDefault("true") - boolean resteasyReactive(); + boolean rest(); /** * Enables instrumentation for RESTEasy Classic. */ @WithDefault("true") - boolean resteasyClassic(); + boolean resteasy(); // NOTE: agroal, graphql and scheduler have their own config properties diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/build/InstrumentBuildTimeConfigFallbackConfigSourceInterceptor.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/build/InstrumentBuildTimeConfigFallbackConfigSourceInterceptor.java new file mode 100644 index 0000000000000..37a21deeca62a --- /dev/null +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/build/InstrumentBuildTimeConfigFallbackConfigSourceInterceptor.java @@ -0,0 +1,40 @@ +package io.quarkus.opentelemetry.runtime.config.build; + +import java.util.function.Function; + +import io.smallrye.config.FallbackConfigSourceInterceptor; + +/** + * @deprecated maps the old config to the new config, should be removed at some point + */ +@Deprecated(forRemoval = true, since = "3.9") +public class InstrumentBuildTimeConfigFallbackConfigSourceInterceptor extends FallbackConfigSourceInterceptor { + + private static final Function RENAME_FUNCTION = new Function() { + @Override + public String apply(String s) { + if (!s.startsWith("quarkus.otel.instrument.")) { + return s; + } + + if ("quarkus.otel.instrument.messaging".equals(s)) { + return "quarkus.otel.instrument.reactive-messaging"; + } + if ("quarkus.otel.instrument.resteasy-client".equals(s)) { + return "quarkus.otel.instrument.rest-client-classic"; + } + if ("quarkus.otel.instrument.rest".equals(s)) { + return "quarkus.otel.instrument.resteasy-reactive"; + } + if ("quarkus.otel.instrument.resteasy".equals(s)) { + return "quarkus.otel.instrument.resteasy-classic"; + } + + return s; + } + }; + + public InstrumentBuildTimeConfigFallbackConfigSourceInterceptor() { + super(RENAME_FUNCTION); + } +} diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/build/InstrumentBuildTimeConfigRelocateConfigSourceInterceptor.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/build/InstrumentBuildTimeConfigRelocateConfigSourceInterceptor.java new file mode 100644 index 0000000000000..41d8b45dc6c17 --- /dev/null +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/build/InstrumentBuildTimeConfigRelocateConfigSourceInterceptor.java @@ -0,0 +1,40 @@ +package io.quarkus.opentelemetry.runtime.config.build; + +import java.util.function.Function; + +import io.smallrye.config.RelocateConfigSourceInterceptor; + +/** + * @deprecated maps the old config to the new config, should be removed at some point + */ +@Deprecated(forRemoval = true, since = "3.9") +public class InstrumentBuildTimeConfigRelocateConfigSourceInterceptor extends RelocateConfigSourceInterceptor { + + private static final Function RENAME_FUNCTION = new Function() { + @Override + public String apply(String s) { + if (!s.startsWith("quarkus.otel.instrument.")) { + return s; + } + + if ("quarkus.otel.instrument.reactive-messaging".equals(s)) { + return "quarkus.otel.instrument.messaging"; + } + if ("quarkus.otel.instrument.rest-client-classic".equals(s)) { + return "quarkus.otel.instrument.resteasy-client"; + } + if ("quarkus.otel.instrument.resteasy-reactive".equals(s)) { + return "quarkus.otel.instrument.rest"; + } + if ("quarkus.otel.instrument.resteasy-classic".equals(s)) { + return "quarkus.otel.instrument.resteasy"; + } + + return s; + } + }; + + public InstrumentBuildTimeConfigRelocateConfigSourceInterceptor() { + super(RENAME_FUNCTION); + } +} diff --git a/extensions/opentelemetry/runtime/src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceInterceptor b/extensions/opentelemetry/runtime/src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceInterceptor index 804c3986d76d8..4a1ed8964d145 100644 --- a/extensions/opentelemetry/runtime/src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceInterceptor +++ b/extensions/opentelemetry/runtime/src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceInterceptor @@ -1 +1,3 @@ io.quarkus.opentelemetry.runtime.config.OTelFallbackConfigSourceInterceptor +io.quarkus.opentelemetry.runtime.config.build.InstrumentBuildTimeConfigFallbackConfigSourceInterceptor +io.quarkus.opentelemetry.runtime.config.build.InstrumentBuildTimeConfigRelocateConfigSourceInterceptor \ No newline at end of file