File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
spring-boot-project/spring-boot-actuator-autoconfigure/src
main/java/org/springframework/boot/actuate/autoconfigure/metrics
test/java/org/springframework/boot/actuate/autoconfigure/metrics Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 1717package org .springframework .boot .actuate .autoconfigure .metrics ;
1818
1919import io .micrometer .core .aop .CountedAspect ;
20+ import io .micrometer .core .aop .CountedMeterTagAnnotationHandler ;
2021import io .micrometer .core .aop .MeterTagAnnotationHandler ;
2122import io .micrometer .core .aop .TimedAspect ;
2223import io .micrometer .core .instrument .MeterRegistry ;
@@ -46,8 +47,10 @@ public class MetricsAspectsAutoConfiguration {
4647
4748 @ Bean
4849 @ ConditionalOnMissingBean
49- CountedAspect countedAspect (MeterRegistry registry ) {
50- return new CountedAspect (registry );
50+ CountedAspect countedAspect (MeterRegistry registry , ObjectProvider <CountedMeterTagAnnotationHandler > countedMeterTagAnnotationHandler ) {
51+ CountedAspect countedAspect = new CountedAspect (registry );
52+ countedMeterTagAnnotationHandler .ifAvailable (countedAspect ::setMeterTagAnnotationHandler );
53+ return countedAspect ;
5154 }
5255
5356 @ Bean
Original file line number Diff line number Diff line change 1717package org .springframework .boot .actuate .autoconfigure .metrics ;
1818
1919import io .micrometer .core .aop .CountedAspect ;
20+ import io .micrometer .core .aop .CountedMeterTagAnnotationHandler ;
2021import io .micrometer .core .aop .MeterTagAnnotationHandler ;
2122import io .micrometer .core .aop .TimedAspect ;
2223import io .micrometer .core .instrument .MeterRegistry ;
@@ -71,6 +72,15 @@ void shouldConfigureMeterTagAnnotationHandler() {
7172 });
7273 }
7374
75+ @ Test
76+ void shouldConfigureCounterMeterTagAnnotationHandler () {
77+ this .contextRunner .withUserConfiguration (MeterTagAnnotationHandlerConfiguration .class ).run ((context ) -> {
78+ assertThat (context ).hasSingleBean (CountedAspect .class );
79+ assertThat (ReflectionTestUtils .getField (context .getBean (CountedAspect .class ), "countedMeterTagAnnotationHandler" ))
80+ .isSameAs (context .getBean (CountedMeterTagAnnotationHandler .class ));
81+ });
82+ }
83+
7484 @ Test
7585 void shouldNotConfigureAspectsIfMicrometerIsMissing () {
7686 this .contextRunner .withClassLoader (new FilteredClassLoader (MeterRegistry .class )).run ((context ) -> {
@@ -128,6 +138,10 @@ MeterTagAnnotationHandler meterTagAnnotationHandler() {
128138 return new MeterTagAnnotationHandler (null , null );
129139 }
130140
141+ @ Bean
142+ CountedMeterTagAnnotationHandler countedMeterTagAnnotationHandler () {
143+ return new CountedMeterTagAnnotationHandler (null , null );
144+ }
131145 }
132146
133147}
You can’t perform that action at this time.
0 commit comments