From da9997d005c0e23e1fe1fdd1c4e61e1e8ae062dd Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Tue, 12 Sep 2023 10:12:31 +0300 Subject: [PATCH] Only remove OTLP trace services when otlp is not configured Fixes: #35786 --- .../deployment/OpenTelemetryProcessor.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/extensions/opentelemetry/deployment/src/main/java/io/quarkus/opentelemetry/deployment/OpenTelemetryProcessor.java b/extensions/opentelemetry/deployment/src/main/java/io/quarkus/opentelemetry/deployment/OpenTelemetryProcessor.java index 0b80f7a871490..983da2a912153 100644 --- a/extensions/opentelemetry/deployment/src/main/java/io/quarkus/opentelemetry/deployment/OpenTelemetryProcessor.java +++ b/extensions/opentelemetry/deployment/src/main/java/io/quarkus/opentelemetry/deployment/OpenTelemetryProcessor.java @@ -61,6 +61,8 @@ import io.quarkus.opentelemetry.runtime.AutoConfiguredOpenTelemetrySdkBuilderCustomizer; import io.quarkus.opentelemetry.runtime.OpenTelemetryRecorder; import io.quarkus.opentelemetry.runtime.QuarkusContextStorage; +import io.quarkus.opentelemetry.runtime.config.build.ExporterType; +import io.quarkus.opentelemetry.runtime.config.build.OTelBuildConfig; import io.quarkus.opentelemetry.runtime.config.runtime.OTelRuntimeConfig; import io.quarkus.opentelemetry.runtime.tracing.cdi.WithSpanInterceptor; import io.quarkus.opentelemetry.runtime.tracing.intrumentation.InstrumentationRecorder; @@ -111,7 +113,8 @@ SyntheticBeanBuildItem openTelemetryBean(OpenTelemetryRecorder recorder, OTelRun } @BuildStep - void registerNativeImageResources(BuildProducer services, + void handleServices(OTelBuildConfig config, + BuildProducer services, BuildProducer removedResources, BuildProducer runtimeReinitialized) throws IOException { @@ -125,9 +128,11 @@ void registerNativeImageResources(BuildProducer servic new ServiceProviderBuildItem(ConfigurableSpanExporterProvider.class.getName(), spanExporterProviders)); } // remove the service file that contains OtlpSpanExporterProvider - removedResources.produce(new RemovedResourceBuildItem( - ArtifactKey.fromString("io.opentelemetry:opentelemetry-exporter-otlp"), - Set.of("META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider"))); + if (config.traces().exporter().stream().noneMatch(ExporterType.Constants.OTLP_VALUE::equals)) { + removedResources.produce(new RemovedResourceBuildItem( + ArtifactKey.fromString("io.opentelemetry:opentelemetry-exporter-otlp"), + Set.of("META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider"))); + } runtimeReinitialized.produce( new RuntimeReinitializedClassBuildItem("io.opentelemetry.sdk.autoconfigure.TracerProviderConfiguration"));