Skip to content
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

Merged
merged 6 commits into from
May 24, 2023
Merged

Enhance boot3-actuator-autoconfigure #4880

merged 6 commits into from
May 24, 2023

Conversation

be-hase
Copy link
Member

@be-hase be-hase commented May 17, 2023

Motivation:

#4874

Modifications:

It should behave the same as spring boot's WebEndpointAutoConfiguration.

  • Support management.endpoints.web.exposure.*
  • Support management.endpoints.web.path-mapping.*
  • Support management.endpoints.web.discovery.*
  • Support management.endpoint.health.status.http-mapping.*
  • Support application/vnd.spring-boot.actuator.v3+json, application/vnd.spring-boot.actuator.v2+json and application/json

Result:

@Bean
@ConditionalOnMissingBean
EndpointMediaTypes endpointMediaTypes() {
return new EndpointMediaTypes(MEDIA_TYPES, MEDIA_TYPES);
public IncludeExcludeEndpointFilter<ExposableWebEndpoint> webExposeExcludePropertyEndpointFilter(
Copy link
Member Author

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) {
Copy link
Member Author

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.*

Copy link
Contributor

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()) {
Copy link
Member Author

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.*

Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

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);
Copy link
Member Author

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.
Copy link
Member Author

@be-hase be-hase May 17, 2023

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)

Copy link
Contributor

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 })
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@be-hase be-hase changed the title Enhance spring boot actuator support Enhance boot3-actuator-autoconfigure May 17, 2023
Copy link
Contributor

@minwoox minwoox left a 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()) {
Copy link
Contributor

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.

import com.google.common.collect.ImmutableMap;

/**
* Copied from spring-boot-actuator 2.3.0 to avoid breaking compatibility.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for cleaning up. 🙇

Copy link
Contributor

@minwoox minwoox left a 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()) {
Copy link
Contributor

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!

@ikhoon ikhoon added this to the 1.24.0 milestone May 22, 2023
Copy link
Contributor

@ikhoon ikhoon left a 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.

// In case WebEndpointAutoConfiguration is excluded
@Bean
@ConditionalOnMissingBean
public PathMapper webEndpointPathMapper(WebEndpointProperties properties) {
Copy link
Contributor

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.

Copy link
Member

@trustin trustin left a 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. 🙇

@be-hase
Copy link
Member Author

be-hase commented May 22, 2023

It would be also useful to comment about management.endpoints.web.path-mapping.* on the method or Javadoc.

fixed: f477edd

Copy link
Contributor

@ikhoon ikhoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @be-hase! 💯🙏

Copy link
Contributor

@jrhee17 jrhee17 left a 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 ! 🙇 👍 🚀

@ikhoon ikhoon merged commit d482f0c into line:main May 24, 2023
@be-hase be-hase deleted the issue-4874 branch May 24, 2023 04:20
@be-hase
Copy link
Member Author

be-hase commented May 24, 2023

Thanks for the review :) > armeria team

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants