micronaut-core icon indicating copy to clipboard operation
micronaut-core copied to clipboard

Discovery of management endpoints

Open hernancerm opened this issue 4 years ago • 9 comments

Solves #5006

Created the endpoint /management to reveal mangament routes in a HATEOAS format. This is the format that Spring Boot's /actuator uses. Example output:

{
  "_links": {
    "self": {
      "href": "http://localhost:8080/management",
      "templated": false
    },
    "threaddump": {
      "href": "http://localhost:8080/threaddump",
      "templated": false
    },
    "loggers": [
      {
        "href": "http://localhost:8080/loggers/{name}",
        "templated": true
      },
      {
        "href": "http://localhost:8080/loggers",
        "templated": false
      }
    ]
}

Considerations:

  • Duplicate route paths are not shown because the output does not provide HTTP method information to differentiate them. For example, if a route accepts GET and HEAD, a single path is shown (not one per method).
  • Regardless of the HTTP method of the route, it is shown if it is a management endpoint. This means that to use some links it is not enough to click on them. I allowed this to keep the design similar to Spring Boot Actuator, since at /actuator it can show /actuator/shutdown which expects a POST, not a GET.
  • The implementation also shows custom endpoints defined by the user.

Work that I think is pending

  • [x] Implement tests for ManagementController

hernancerm avatar Jul 07 '21 14:07 hernancerm

Thinking about this more it seems like it would be better done with a controller if the goal is to discover the HTTP links

jameskleeh avatar Jul 07 '21 16:07 jameskleeh

Thinking about this more it seems like it would be better done with a controller if the goal is to discover the HTTP links

@jameskleeh By using a controller, would an EmbeddedServer injected in the controller return the correct scheme, host and port to create the links? I think that having clickable links as the author of the issue mentions would be helpful for navigation

hernancerm avatar Jul 07 '21 16:07 hernancerm

Thinking about this more it seems like it would be better done with a controller if the goal is to discover the HTTP links

@jameskleeh By using a controller, would an EmbeddedServer injected in the controller return the correct scheme, host and port to create the links? I think that having clickable links as the author of the issue mentions would be helpful for navigation

No you would have to inject the HttpHostResolver

jameskleeh avatar Jul 07 '21 16:07 jameskleeh

@jameskleeh I've addressed your suggestions, now I'm also targeting branch 3.0.x

hernancerm avatar Jul 07 '21 21:07 hernancerm

@jameskleeh I've implemented the tests for the management controller.

Locally ./gradlew check passes all tests

hernancerm avatar Jul 08 '21 22:07 hernancerm

Hi @jameskleeh, are there additional changes that I should make?

hernancerm avatar Jul 16 '21 14:07 hernancerm

@HerCerM Overall it looks OK however we are hard at work getting the next milestone of 3.0 out so we'll get this merged afterwards

jameskleeh avatar Jul 16 '21 15:07 jameskleeh

Hi @graemerocher, thanks for the review and sorry for the delay. I expect to address the changes during the next week, since currently I have other things at hand

hernancerm avatar Sep 28 '21 15:09 hernancerm

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

CLAassistant avatar Feb 07 '24 21:02 CLAassistant