diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/cache/InflightReadsLimiterTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/cache/InflightReadsLimiterTest.java index 281f19e388837..68135598e3339 100644 --- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/cache/InflightReadsLimiterTest.java +++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/cache/InflightReadsLimiterTest.java @@ -28,6 +28,7 @@ import io.opentelemetry.sdk.OpenTelemetrySdk; import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk; import io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader; +import java.util.Map; import lombok.Cleanup; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.tuple.Pair; @@ -207,6 +208,9 @@ private Pair buildOpenTelemetryAndReader var metricReader = InMemoryMetricReader.create(); var openTelemetry = AutoConfiguredOpenTelemetrySdk.builder() .disableShutdownHook() + .addPropertiesSupplier(() -> Map.of("otel.metrics.exporter", "none", + "otel.traces.exporter", "none", + "otel.logs.exporter", "none")) .addMeterProviderCustomizer((builder, __) -> builder.registerMetricReader(metricReader)) .build() .getOpenTelemetrySdk(); diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/stats/BrokerOpenTelemetryTestUtil.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/stats/BrokerOpenTelemetryTestUtil.java index 69653ea26e240..0d46e80a70302 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/stats/BrokerOpenTelemetryTestUtil.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/stats/BrokerOpenTelemetryTestUtil.java @@ -36,12 +36,20 @@ public static Consumer getOpenTelemetrySd sdkBuilder.addMeterProviderCustomizer( (meterProviderBuilder, __) -> meterProviderBuilder.registerMetricReader(reader)); sdkBuilder.disableShutdownHook(); + disableExporters(sdkBuilder); sdkBuilder.addPropertiesSupplier( () -> Map.of(OpenTelemetryService.OTEL_SDK_DISABLED_KEY, "false", "otel.java.enabled.resource.providers", "none")); }; } + public static void disableExporters(AutoConfiguredOpenTelemetrySdkBuilder sdkBuilder) { + sdkBuilder.addPropertiesSupplier(() -> + Map.of("otel.metrics.exporter", "none", + "otel.traces.exporter", "none", + "otel.logs.exporter", "none")); + } + public static void assertMetricDoubleSumValue(Collection metrics, String metricName, Attributes attributes, Consumer valueConsumer) { assertThat(metrics) diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/testcontext/PulsarTestContext.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/testcontext/PulsarTestContext.java index cdb047079bfcd..6403c3bcec4c3 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/testcontext/PulsarTestContext.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/testcontext/PulsarTestContext.java @@ -761,7 +761,8 @@ protected void initializePulsarServices(SpyConfig spyConfig, Builder builder) { var reader = InMemoryMetricReader.create(); openTelemetryMetricReader(reader); registerCloseable(reader); - openTelemetrySdkBuilderCustomizer = BrokerOpenTelemetryTestUtil.getOpenTelemetrySdkBuilderConsumer(reader); + openTelemetrySdkBuilderCustomizer = + BrokerOpenTelemetryTestUtil.getOpenTelemetrySdkBuilderConsumer(reader); } else { openTelemetrySdkBuilderCustomizer = null; } diff --git a/pulsar-opentelemetry/src/test/java/org/apache/pulsar/opentelemetry/OpenTelemetryServiceTest.java b/pulsar-opentelemetry/src/test/java/org/apache/pulsar/opentelemetry/OpenTelemetryServiceTest.java index f1a7ffaa12289..99d4189d8f803 100644 --- a/pulsar-opentelemetry/src/test/java/org/apache/pulsar/opentelemetry/OpenTelemetryServiceTest.java +++ b/pulsar-opentelemetry/src/test/java/org/apache/pulsar/opentelemetry/OpenTelemetryServiceTest.java @@ -76,6 +76,11 @@ private static Consumer getBuilderCustomi (sdkMeterProviderBuilder, __) -> sdkMeterProviderBuilder.registerMetricReader(extraReader)); } autoConfigurationCustomizer.disableShutdownHook(); + // disable all autoconfigured exporters + autoConfigurationCustomizer.addPropertiesSupplier(() -> + Map.of("otel.metrics.exporter", "none", + "otel.traces.exporter", "none", + "otel.logs.exporter", "none")); autoConfigurationCustomizer.addPropertiesSupplier(() -> extraProperties); }; }