Skip to content

Commit b5941b9

Browse files
committed
Make sure it is possible to override neo4jObservationCustomizer
At present, the `neo4jObservationCustomizer` has an effective `Ordered.LOWEST_PRECEDENCE`, meaning that it goes last in `Neo4jAutoConfiguration`: ```java configBuilderCustomizers.orderedStream().toList() ... customizers.forEach((customizer) -> customizer.customize(builder)); ``` This update set its order to `Ordered.HIGHEST_PRECEDENCE`, meaning that a user-defined `ConfigBuilderCustomizer` can effectively override it. As an example, this is useful when user wants to customize `MicrometerObservationProvider` as it actually has some optional properties that may be useful. Here is an example: ```java @bean ConfigBuilderCustomizer observationCustomizer(ObservationRegistry observationRegistry) { return configBuilder -> { var observationProvider = MicrometerObservationProvider.builder(observationRegistry) .alwaysIncludeQuery(true) .includeQueryParameters(true) .includeUrlScheme(true) .includeUrlTemplate(true) .requestHeaderPredicate(name -> true) .responseHeaderPredicate(name -> true) .build(); configBuilder.withObservationProvider(observationProvider); }; } ```
1 parent 0c7e49e commit b5941b9

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

module/spring-boot-neo4j/src/main/java/org/springframework/boot/neo4j/autoconfigure/observation/Neo4jObservationAutoConfiguration.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import org.springframework.boot.neo4j.autoconfigure.ConfigBuilderCustomizer;
2828
import org.springframework.boot.neo4j.autoconfigure.Neo4jAutoConfiguration;
2929
import org.springframework.context.annotation.Bean;
30+
import org.springframework.core.Ordered;
31+
import org.springframework.core.annotation.Order;
3032

3133
/**
3234
* Auto-configuration for Neo4j observability.
@@ -42,6 +44,7 @@ public final class Neo4jObservationAutoConfiguration {
4244

4345
@Bean
4446
@ConditionalOnBean(ObservationRegistry.class)
47+
@Order(Ordered.HIGHEST_PRECEDENCE)
4548
ConfigBuilderCustomizer neo4jObservationCustomizer(ObservationRegistry registry) {
4649
return (builder) -> builder.withObservationProvider(MicrometerObservationProvider.builder(registry).build());
4750
}

0 commit comments

Comments
 (0)