Skip to content

Commit

Permalink
Only remove OTLP trace services when otlp is not configured
Browse files Browse the repository at this point in the history
Fixes: #35786
(cherry picked from commit da9997d)
  • Loading branch information
geoand authored and gsmet committed Sep 13, 2023
1 parent cff52ff commit 2715552
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -111,7 +113,8 @@ SyntheticBeanBuildItem openTelemetryBean(OpenTelemetryRecorder recorder, OTelRun
}

@BuildStep
void registerNativeImageResources(BuildProducer<ServiceProviderBuildItem> services,
void handleServices(OTelBuildConfig config,
BuildProducer<ServiceProviderBuildItem> services,
BuildProducer<RemovedResourceBuildItem> removedResources,
BuildProducer<RuntimeReinitializedClassBuildItem> runtimeReinitialized) throws IOException {

Expand All @@ -125,9 +128,11 @@ void registerNativeImageResources(BuildProducer<ServiceProviderBuildItem> 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"));
Expand Down

0 comments on commit 2715552

Please sign in to comment.