micronaut-projects / micronaut-core

Micronaut Application Framework
http://micronaut.io
Apache License 2.0
6.06k stars 1.06k forks source link

Discovery view for management endpoints #5006

Open drmaciej opened 3 years ago

drmaciej commented 3 years ago

Endpoints are described here https://docs.micronaut.io/2.3.3/guide/index.html#providedEndpoints. Boot has such a view at /actuator, enabled via EndpointLinksResolver and WebMvcEndpointHandlerMapping. A similar view would be very useful in Micronaut. In the meantime - until this does or does not become available - is there a way to discover all enabled @Endpoint-annotated classes, so I could build such a view myself?

Task List

Steps to Reproduce

  1. Run any sample application with endpoints.all.enabled set to true.

Expected Behaviour

A management discovery endpoint, say /management, listing all available endpoints, together with their links, is available.

Actual Behaviour

This is not available.

Environment Information

Example Application

graemerocher commented 3 years ago

PRs welcome!

jameskleeh commented 3 years ago

We have a routes endpoint which will include the management endpoints. You can have a ExecutableMethodProcessor<Endpoint> bean, however you wouldn't have access to the logic that determines the URL, etc...

drmaciej commented 3 years ago

I'm aware of the routes endpoint, I was hoping for something with clickable links though. I'll have a look at the ExecutableMethodProcessor, perhaps it takes me somewhere.

drmaciej commented 3 years ago

I have had a look; I may be able to come up with a PR soon; just need to figure out a bit more in terms of Micronaut internals.

hernancerm commented 3 years ago

Hi @jameskleeh, could I tackle this issue?

I'm thinking that the expected response should be like Boot's /actuator, like the following:

Spring Boot's /actuator ```json { "_links": { "self": { "href": "http://localhost:8080/actuator", "templated": false }, "beans": { "href": "http://localhost:8080/actuator/beans", "templated": false }, "health": { "href": "http://localhost:8080/actuator/health", "templated": false }, "health-path": { "href": "http://localhost:8080/actuator/health/{*path}", "templated": true } } } ```

Is this response format appropriate for the new endpoint?

jameskleeh commented 3 years ago

@HerCerM Seems reasonable to me

hernancerm commented 3 years ago

@jameskleeh I've made a PR with a working implementation. I would like to know if I'm in the right direction before implementing the tests

drmaciej commented 3 years ago

I never got around to it - thanks @HerCerM!