Skip to content

Commit c726a13

Browse files
committed
Polish "Add auto-configuration for ObservedAspect"
See gh-35191
1 parent 0dae89e commit c726a13

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/ObservationAutoConfigurationTests.java

+18
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,14 @@ void allowsObservedAspectToBeDisabled() {
180180
.run((context) -> assertThat(context).doesNotHaveBean(ObservedAspect.class));
181181
}
182182

183+
@Test
184+
void allowsObservedAspectToBeCustomized() {
185+
this.contextRunner.withUserConfiguration(CustomObservedAspectConfiguration.class)
186+
.run((context) -> assertThat(context).hasSingleBean(ObservedAspect.class)
187+
.getBean(ObservedAspect.class)
188+
.isSameAs(context.getBean("customObservedAspect")));
189+
}
190+
183191
@Test
184192
void autoConfiguresObservationPredicates() {
185193
this.contextRunner.withUserConfiguration(ObservationPredicates.class).run((context) -> {
@@ -353,6 +361,16 @@ ObservationFilter observationFilterTwo() {
353361

354362
}
355363

364+
@Configuration(proxyBeanMethods = false)
365+
static class CustomObservedAspectConfiguration {
366+
367+
@Bean
368+
ObservedAspect customObservedAspect(ObservationRegistry observationRegistry) {
369+
return new ObservedAspect(observationRegistry);
370+
}
371+
372+
}
373+
356374
@Configuration(proxyBeanMethods = false)
357375
static class CustomGlobalObservationConvention {
358376

0 commit comments

Comments
 (0)