Skip to content

Fix Spring Boot 4 Micrometer auto-configuration and add actuator metrics smoke coverage#4672

Open
xiang17 wants to merge 7 commits intomicrosoft:mainfrom
xiang17:xiang17/SpringBoot4-ActuatorMetrics
Open

Fix Spring Boot 4 Micrometer auto-configuration and add actuator metrics smoke coverage#4672
xiang17 wants to merge 7 commits intomicrosoft:mainfrom
xiang17:xiang17/SpringBoot4-ActuatorMetrics

Conversation

@xiang17
Copy link
Copy Markdown
Member

@xiang17 xiang17 commented Apr 4, 2026

Fix #4577.

Spring Boot 4 moved Micrometer metrics auto-configuration classes from
org.springframework.boot.actuate.autoconfigure.metrics.* to
org.springframework.boot.micrometer.metrics.autoconfigure.*.

Our Micrometer instrumentation was still keyed only to the Spring Boot 3 class
names, which meant the Azure Monitor meter registry auto-configuration was not
being inserted for Spring Boot 4 applications. As a result, custom Micrometer
metrics such as demo.requests.total could be present locally but never reach
Application Insights.

This change updates the Micrometer instrumentation to support both Spring Boot 3
and Spring Boot 4 auto-configuration class names, and adds smoke coverage for
the Spring Boot 4 path.

Docs for reference

Old package summary, Spring Boot 3.5.8
https://javadoc.io/static/org.springframework.boot/spring-boot-actuator-autoconfigure/3.5.8/org/springframework/boot/actuate/autoconfigure/metrics/package-summary.html
This page explicitly says:
Package org.springframework.boot.actuate.autoconfigure.metrics
Auto-configuration for actuator metrics and Micrometer.

New package summary, Spring Boot 4.0.0
https://javadoc.io/static/org.springframework.boot/spring-boot-micrometer-metrics/4.0.0/org/springframework/boot/micrometer/metrics/autoconfigure/package-summary.html
This page explicitly says:
Package org.springframework.boot.micrometer.metrics.autoconfigure
Auto-configuration for metrics with Micrometer.

Suggested testing

  • ./gradlew :smoke-tests:apps:ActuatorMetricsSpringBoot4:smokeTest --tests '*ActuatorMetricsSpringBoot4Test$Java21Test'
  • ./gradlew :smoke-tests:apps:Micrometer:smokeTest --tests "*MicrometerTest*"

xiang17 added 6 commits April 3, 2026 19:03
… Boot 4 logging so the test can reach the intended Micrometer failure path. 2. making one small adjustment so the app boots with a local SimpleMeterRegistry and the test fails exactly on the missing AI metric behavior
…ame to org.springframework.boot.micrometer.metrics.autoconfigure.* (different module/package)
@xiang17 xiang17 marked this pull request as ready for review April 5, 2026 00:35
return false;
}

@Environment(JAVA_17)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


@Bean
public MeterRegistry meterRegistry() {
return Metrics.globalRegistry;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think returning Metrics.globalRegistry here bypasses the new Spring Boot 4 actuator auto-configuration path. MetricsInstrumentation already adds AzureMonitorMeterRegistry to the global registry, so this smoke test can stay green even if the PR's Boot 4 import hook never runs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could try reverting your fix and re-running this smoke test to make sure it fails without your fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Micrometer metrics not pushed to Application Insights after upgrade to Spring Boot 4.0.0

2 participants