Skip to content

Commit 2f1b2e3

Browse files
committed
Log summary of web-exposed endpoints during startup
Closes gh-12442
1 parent f758a4d commit 2f1b2e3

File tree

4 files changed

+33
-4
lines changed

4 files changed

+33
-4
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/jersey/JerseyWebEndpointManagementContextConfiguration.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import org.springframework.boot.actuate.endpoint.web.EndpointMediaTypes;
3434
import org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint;
3535
import org.springframework.boot.actuate.endpoint.web.WebEndpointsSupplier;
36-
import org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpointsSupplier;
3736
import org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpointsSupplier;
3837
import org.springframework.boot.actuate.endpoint.web.jersey.JerseyEndpointResourceFactory;
3938
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
@@ -76,7 +75,7 @@ public ResourceConfigCustomizer webEndpointRegistrar(
7675
resourceConfig.registerResources(
7776
new HashSet<>(resourceFactory.createEndpointResources(endpointMapping,
7877
webEndpoints, endpointMediaTypes,
79-
new EndpointLinksResolver(allEndpoints))));
78+
new EndpointLinksResolver(allEndpoints, basePath))));
8079
};
8180
}
8281

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/reactive/WebFluxEndpointManagementContextConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ public WebFluxEndpointHandlerMapping webEndpointReactiveHandlerMapping(
7272
allEndpoints.addAll(controllerEndpointsSupplier.getEndpoints());
7373
return new WebFluxEndpointHandlerMapping(endpointMapping, endpoints,
7474
endpointMediaTypes, corsProperties.toCorsConfiguration(),
75-
new EndpointLinksResolver(allEndpoints));
75+
new EndpointLinksResolver(allEndpoints,
76+
webEndpointProperties.getBasePath()));
7677
}
7778

7879
@Bean

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/servlet/WebMvcEndpointManagementContextConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ public WebMvcEndpointHandlerMapping webEndpointServletHandlerMapping(
7575
webEndpointProperties.getBasePath());
7676
return new WebMvcEndpointHandlerMapping(endpointMapping, webEndpoints,
7777
endpointMediaTypes, corsProperties.toCorsConfiguration(),
78-
new EndpointLinksResolver(allEndpoints));
78+
new EndpointLinksResolver(allEndpoints,
79+
webEndpointProperties.getBasePath()));
7980
}
8081

8182
@Bean

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/EndpointLinksResolver.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
import java.util.LinkedHashMap;
2121
import java.util.Map;
2222

23+
import org.apache.commons.logging.Log;
24+
import org.apache.commons.logging.LogFactory;
25+
2326
import org.springframework.boot.actuate.endpoint.ExposableEndpoint;
2427

2528
/**
@@ -30,12 +33,37 @@
3033
*/
3134
public class EndpointLinksResolver {
3235

36+
private static final Log logger = LogFactory.getLog(EndpointLinksResolver.class);
37+
3338
private final Collection<? extends ExposableEndpoint<?>> endpoints;
3439

40+
/**
41+
* Creates a new {@code EndpointLinksResolver} that will resolve links to the given
42+
* {@code endpoints}.
43+
* @param endpoints the endpoints
44+
* @deprecated since 2.0.1 in favor of
45+
* {@link #EndpointLinksResolver(Collection, String)}
46+
*/
47+
@Deprecated
3548
public EndpointLinksResolver(Collection<? extends ExposableEndpoint<?>> endpoints) {
3649
this.endpoints = endpoints;
3750
}
3851

52+
/**
53+
* Creates a new {@code EndpointLinksResolver} that will resolve links to the given
54+
* {@code endpoints} that are exposed beneath the given {@code basePath}.
55+
* @param endpoints the endpoints
56+
* @param basePath the basePath
57+
*/
58+
public EndpointLinksResolver(Collection<? extends ExposableEndpoint<?>> endpoints,
59+
String basePath) {
60+
this.endpoints = endpoints;
61+
if (logger.isInfoEnabled()) {
62+
logger.info("Exposing " + endpoints.size()
63+
+ " endpoint(s) beneath base path '" + basePath + "'");
64+
}
65+
}
66+
3967
/**
4068
* Resolves links to the known endpoints based on a request with the given
4169
* {@code requestUrl}.

0 commit comments

Comments
 (0)