From e8bba81665fda564d4ea2cfa1c5d363d8081d165 Mon Sep 17 00:00:00 2001 From: Jonas Kunz Date: Wed, 20 Sep 2023 12:33:53 +0200 Subject: [PATCH] OpenTelemetry metrics exporter instrumentation should be enabled even with instrument=false --- .../SdkMeterProviderBuilderInstrumentation.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metricsdk-plugin/src/main/java/co/elastic/apm/agent/otelmetricsdk/SdkMeterProviderBuilderInstrumentation.java b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metricsdk-plugin/src/main/java/co/elastic/apm/agent/otelmetricsdk/SdkMeterProviderBuilderInstrumentation.java index 91b982a349..2cc64c554c 100644 --- a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metricsdk-plugin/src/main/java/co/elastic/apm/agent/otelmetricsdk/SdkMeterProviderBuilderInstrumentation.java +++ b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-metricsdk-plugin/src/main/java/co/elastic/apm/agent/otelmetricsdk/SdkMeterProviderBuilderInstrumentation.java @@ -19,13 +19,13 @@ package co.elastic.apm.agent.otelmetricsdk; import co.elastic.apm.agent.impl.ElasticApmTracer; -import co.elastic.apm.agent.tracer.GlobalTracer; import co.elastic.apm.agent.sdk.ElasticApmInstrumentation; +import co.elastic.apm.agent.sdk.internal.util.LoggerUtils; import co.elastic.apm.agent.sdk.logging.Logger; import co.elastic.apm.agent.sdk.logging.LoggerFactory; import co.elastic.apm.agent.sdk.weakconcurrent.WeakConcurrent; import co.elastic.apm.agent.sdk.weakconcurrent.WeakSet; -import co.elastic.apm.agent.sdk.internal.util.LoggerUtils; +import co.elastic.apm.agent.tracer.GlobalTracer; import io.opentelemetry.sdk.metrics.SdkMeterProviderBuilder; import io.opentelemetry.sdk.metrics.export.MetricExporter; import net.bytebuddy.asm.Advice; @@ -55,6 +55,11 @@ public Collection getInstrumentationGroupNames() { return Arrays.asList("opentelemetry", "opentelemetry-metrics", "experimental"); } + @Override + public final boolean includeWhenInstrumentationIsDisabled() { + return true; + } + @Override public String getAdviceClassName() { return getClass().getName() + "$SdkMeterProviderBuilderAdvice";