Skip to content

Improve documentation of how actuator integrates with both Jersey and Spring MVC #17523

Closed
@bric3

Description

@bric3

Following a suggestion from @wilkinsona on this #2025 (comment), I'm opening this issue, as I believe there could be some refinement in the documentation and in the code too regarding the exposure of actuator endpoints


Reading this https://docs.spring.io/spring-boot/docs/2.1.6.RELEASE/reference/htmlsingle/#production-ready-customizing-management-server-context-path (Using 2.1.6.RELEASE)

Unless the management port has been configured to expose endpoints by using a different HTTP port, management.endpoints.web.base-path is relative to server.servlet.context-path. If management.server.port is configured, management.endpoints.web.base-path is relative to management.server.servlet.context-path.

I modified the configuration this way

+server:
+  servlet:
+    context-path: /
spring.mvc.servlet.path: /static
spring:
  jersey:
    application-path: /
    servlet:
      load-on-startup: 1

management:
  endpoint:
    health.enabled: true
+  endpoints:
+    web:
+      base-path: /actuator
+      path-mapping.health: healthcheck

However actuators keep showing up under /static instead of /

  • curl localhost:8080/static/actuator/healthcheck => 200
  • curl localhost:8080/actuator/healthcheck => 404

So either there's something missing on the documentation or they are some limitations to how actuator integrate when there's both spring mvc and jersey.

Even switching the dispatcher servlet to / didn't work

-spring.mvc.servlet.path: /static
+spring.mvc.servlet.path: /

From my points over there #2025 (comment) I iterated a bit on the refinement in this area.

  1. The doc should state which technology it will take precedence. And as such how other properties are affected, i.e. server.servlet.context-path has no effect when Spring MVC is also present.
  2. Is there a way to configure which technology will be used to expose actuators?
  3. Is there a way to configure an actuator only (Spring MVC) servlet ?
  4. If there's no way to do the above maybe indicate how to play with the DispatcherServlet or a filter that can make use of a request dispatcher.

When the spring.mvc.servlet.path: / there this log:

Mapping servlets: oldMetricsService urls=[/metrics], company.web.JerseyConfig urls=[/*], dispatcherServlet urls=[/]

This makes sense as the Jersey app intercepts everything on /*

This last is actually interesting if one want to migrate one endpoint at a time from one technology to another.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions