Skip to content

Commit

Permalink
Breaking change: disable micrometer bridge by default (#10038)
Browse files Browse the repository at this point in the history
  • Loading branch information
zeitlinger authored Dec 12, 2023
1 parent 14dc34e commit 3213c86
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,8 @@ tasks {
dependsOn(testPrometheusMode)
dependsOn(testHistogramGauges)
}

withType<Test>().configureEach {
jvmArgs("-Dotel.instrumentation.micrometer.enabled=true")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.google.auto.service.AutoService;
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import java.util.Collections;
import java.util.List;
import net.bytebuddy.matcher.ElementMatcher;
Expand All @@ -21,6 +22,12 @@ public MicrometerInstrumentationModule() {
super("micrometer", "micrometer-1.5");
}

@Override
public boolean defaultEnabled(ConfigProperties config) {
// produces a lot of metrics that are already captured - e.g. JVM memory usage
return false;
}

@Override
public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
// added in 1.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@AutoConfigureBefore(CompositeMeterRegistryAutoConfiguration.class)
@ConditionalOnBean({Clock.class, OpenTelemetry.class})
@ConditionalOnClass(MeterRegistry.class)
@ConditionalOnProperty(name = "otel.instrumentation.micrometer.enabled", matchIfMissing = true)
@ConditionalOnProperty(name = "otel.instrumentation.micrometer.enabled")
@Configuration
public class MicrometerBridgeAutoConfiguration {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,10 @@ void metricsEnabled() {
}

@Test
void metricsEnabledByDefault() {
void metricsDisabledByDefault() {
runner
.withConfiguration(AutoConfigurations.of(MetricsAutoConfiguration.class))
.run(
context ->
assertThat(context.getBean("otelMeterRegistry", MeterRegistry.class))
.isNotNull()
.isInstanceOf(OpenTelemetryMeterRegistry.class));
.run(context -> assertThat(context.containsBean("otelMeterRegistry")).isFalse());
}

@Test
Expand Down

0 comments on commit 3213c86

Please sign in to comment.