-
Notifications
You must be signed in to change notification settings - Fork 936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance boot3-actuator-autoconfigure
#4880
Conversation
@Bean | ||
@ConditionalOnMissingBean | ||
EndpointMediaTypes endpointMediaTypes() { | ||
return new EndpointMediaTypes(MEDIA_TYPES, MEDIA_TYPES); | ||
public IncludeExcludeEndpointFilter<ExposableWebEndpoint> webExposeExcludePropertyEndpointFilter( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Support management.endpoints.web.exposure.*
// In case WebEndpointAutoConfiguration is excluded | ||
@Bean | ||
@ConditionalOnMissingBean | ||
public PathMapper webEndpointPathMapper(WebEndpointProperties properties) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For management.endpoints.web.path-mapping.*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be also useful to comment about management.endpoints.web.path-mapping.*
on the method or Javadoc.
@@ -263,7 +279,7 @@ private static void configureExposableWebEndpoint(ServerBuilder sb, @Nullable In | |||
predicate, path, ImmutableMap.of(), cors); | |||
}); | |||
|
|||
if (StringUtils.hasText(endpointMapping.getPath())) { | |||
if (StringUtils.hasText(endpointMapping.getPath()) && properties.getDiscovery().isEnabled()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For management.endpoints.web.discovery.*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not your fault but we also need to check if the endpointMapping.getPath()
is /
.
When the management context path is set to /, the discovery page is disabled to prevent the possibility of a clash with other mappings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. The case seems to have already been taken care of.
It is normalized to "/" -> "" in WebEndpointProperties.
https://github.com/spring-projects/spring-boot/blob/e3aac5913ed3caf53b34eb7750138a4ed6839549/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java#L69-L74
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't notice that. 😓 Thanks!
@@ -273,7 +289,8 @@ private static void configureExposableWebEndpoint(ServerBuilder sb, @Nullable In | |||
final HttpService linksService = (ctx, req) -> { | |||
final Map<String, Link> links = | |||
new EndpointLinksResolver(endpoints).resolveLinks(req.path()); | |||
return HttpResponse.ofJson(ACTUATOR_MEDIA_TYPE, ImmutableMap.of("_links", links)); | |||
final MediaType contentType = firstNonNull(ctx.negotiatedResponseMediaType(), MediaType.JSON); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For supporting application/vnd.spring-boot.actuator.v3+json
, application/vnd.spring-boot.actuator.v2+json
and application/json
import com.google.common.collect.ImmutableMap; | ||
|
||
/** | ||
* Copied from spring-boot-actuator 2.3.0 to avoid breaking compatibility. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think spring boot 2.3.x is EOL, so we won't have to take care of breaking compatibility anymore.
(No more users in trouble between 2.2.x and 2.3.x)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for cleaning up. 🙇
@@ -45,7 +46,7 @@ | |||
@DirtiesContext | |||
@AutoConfigureMetrics | |||
@EnableAutoConfiguration | |||
@ImportAutoConfiguration(ArmeriaSpringActuatorAutoConfiguration.class) | |||
@ImportAutoConfiguration({ ArmeriaSpringActuatorAutoConfiguration.class, JmxEndpointAutoConfiguration.class }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applying JmxEndpointAutoConfiguration, we can reproduce #4874 .
(Occurs when the Endpoint is registered in a bean.)
code hints:
- https://github.com/be-hase/spring-boot/blob/c4de86c244acdcff69ed0aecacd254399be79ce2/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java#L130-L139
- https://github.com/spring-projects/spring-boot/blob/main/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/condition/OnAvailableEndpointCondition.java
boot3-actuator-autoconfigure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left minor comments. Thanks a lot for fixing this! 👍
@@ -263,7 +279,7 @@ private static void configureExposableWebEndpoint(ServerBuilder sb, @Nullable In | |||
predicate, path, ImmutableMap.of(), cors); | |||
}); | |||
|
|||
if (StringUtils.hasText(endpointMapping.getPath())) { | |||
if (StringUtils.hasText(endpointMapping.getPath()) && properties.getDiscovery().isEnabled()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not your fault but we also need to check if the endpointMapping.getPath()
is /
.
When the management context path is set to /, the discovery page is disabled to prevent the possibility of a clash with other mappings.
...onfigure/src/main/java/com/linecorp/armeria/spring/actuate/MappingWebEndpointPathMapper.java
Outdated
Show resolved
Hide resolved
import com.google.common.collect.ImmutableMap; | ||
|
||
/** | ||
* Copied from spring-boot-actuator 2.3.0 to avoid breaking compatibility. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for cleaning up. 🙇
spring/boot3-actuator-autoconfigure/src/test/resources/application-autoConfTest.yml
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thanks a lot, @be-hase!
@@ -263,7 +279,7 @@ private static void configureExposableWebEndpoint(ServerBuilder sb, @Nullable In | |||
predicate, path, ImmutableMap.of(), cors); | |||
}); | |||
|
|||
if (StringUtils.hasText(endpointMapping.getPath())) { | |||
if (StringUtils.hasText(endpointMapping.getPath()) && properties.getDiscovery().isEnabled()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't notice that. 😓 Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, looks nice. Left only minor comments.
...onfigure/src/main/java/com/linecorp/armeria/spring/actuate/MappingWebEndpointPathMapper.java
Show resolved
Hide resolved
...onfigure/src/main/java/com/linecorp/armeria/spring/actuate/MappingWebEndpointPathMapper.java
Show resolved
Hide resolved
// In case WebEndpointAutoConfiguration is excluded | ||
@Bean | ||
@ConditionalOnMissingBean | ||
public PathMapper webEndpointPathMapper(WebEndpointProperties properties) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be also useful to comment about management.endpoints.web.path-mapping.*
on the method or Javadoc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, @be-hase! Thanks for this PR that requires good understanding of Spring. 🙇
fixed: f477edd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @be-hase! 💯🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really nice 👍 Thanks @be-hase ! 🙇 👍 🚀
Thanks for the review :) > armeria team |
Motivation:
#4874
Modifications:
It should behave the same as spring boot's WebEndpointAutoConfiguration.
management.endpoints.web.exposure.*
management.endpoints.web.path-mapping.*
management.endpoints.web.discovery.*
management.endpoint.health.status.http-mapping.*
application/vnd.spring-boot.actuator.v3+json
,application/vnd.spring-boot.actuator.v2+json
andapplication/json
Result:
management.endpoints.web.exposure
setting in spring boot is not supported byarmeria-spring-boot3-actuator-starter
. #4874