-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Introduce @ConditonalOnExposedEndpoint to avoid auto-configuring endpoints that cannot be accessed #16093
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
Comments
I’m not sure about point 3. Exposure and enablement are two distinct concepts at the moment and I think that’s a good thing. Exposure builds on top of enablement – an endpoint has to be enabled for it to be possible for it to be exposed. If the enabled condition take exposure into account we’ll lose the distinction and it feels the wrong way round for enablement to be aware of exposure. I wonder if we need a new condition for exposure? This could either consider both exposure and enablement or it could just consider exposure and we’d use it and the enabled condition in most (all?) cases. |
Good points @wilkinsona , I'll rework that with a |
Prior to this commit, Actuator `Endpoint` instantiations would be guarded by `@ConditionalOnEnabledEnpoint` condition annotations. This feature saves resources as disabled endpoints aren't unnecessarily instantiated. By default, only `"health"` and "`info`" endpoints are exposed over the web and all endpoints are exposed over JMX. As of spring-projectsgh-16090, JMX is now disabled by default. This is an opportunity to avoid instantiating endpoints if they won't be exposed at all, which is more likely due to the exposure defaults. This commit adds a new `@ConditionalOnExposedEndpoint` conditional annotation that checks the `Environment` for configuration properties under `"management.endpoints.web.exposure.*"` and `"management.endpoints.jmx.exposure.*"`. In the case of JMX, an additional check is perfomed, checking that JMX is enabled first. The rules implemented in the condition itself are following the ones described in `ExposeExcludePropertyEndpointFilter`. See spring-projectsgh-16093
Prior to this commit, Actuator `Endpoint` instantiations would be guarded by `@ConditionalOnEnabledEnpoint` condition annotations. This feature saves resources as disabled endpoints aren't unnecessarily instantiated. By default, only `"health"` and `"info"` endpoints are exposed over the web and all endpoints are exposed over JMX. As of spring-projectsgh-16090, JMX is now disabled by default. This is an opportunity to avoid instantiating endpoints if they won't be exposed at all, which is more likely due to the exposure defaults. This commit adds a new `@ConditionalOnExposedEndpoint` conditional annotation that checks the `Environment` for configuration properties under `"management.endpoints.web.exposure.*"` and `"management.endpoints.jmx.exposure.*"`. In the case of JMX, an additional check is perfomed, checking that JMX is enabled first. The rules implemented in the condition itself are following the ones described in `ExposeExcludePropertyEndpointFilter`. See spring-projectsgh-16093
Prior to this commit, Actuator `Endpoint` instantiations would be guarded by `@ConditionalOnEnabledEnpoint` condition annotations. This feature saves resources as disabled endpoints aren't unnecessarily instantiated. By default, only `"health"` and `"info"` endpoints are exposed over the web and all endpoints are exposed over JMX. As of gh-16090, JMX is now disabled by default. This is an opportunity to avoid instantiating endpoints if they won't be exposed at all, which is more likely due to the exposure defaults. This commit adds a new `@ConditionalOnExposedEndpoint` conditional annotation that checks the `Environment` for configuration properties under `"management.endpoints.web.exposure.*"` and `"management.endpoints.jmx.exposure.*"`. In the case of JMX, an additional check is perfomed, checking that JMX is enabled first. The rules implemented in the condition itself are following the ones described in `ExposeExcludePropertyEndpointFilter`. See gh-16093
The current implementation is completely separating enablement and exposure. |
@bclozel should we move that comment to a new issue targeted to M2? |
Since #16090, the
spring.jmx.enabled
property has been set tofalse
by default.With that change, we should re-evaluate default enablement of Actuator endpoints since:
"info"
and"health"
are exposed over HTTPWe could in this case avoid creating endpoints when possible; we should refine
OnEnabledEndpointCondition
and decide to enable a given endpoint with the following conditions (for example, with the"env"
endpoint):"management.endpoint.env.enabled"
"management.endpoints.enabled-by-default"
@Endpoint(id = "env", enableByDefault = true)
and it is exposed as an HTTP endpoint (see"management.endpoints.web.exposure.include"
) or JMX is enabled and this endpoint is exposed over JMX (see"spring.jmx.enabled"
and"management.endpoints.jmx.exposure.include"
)With this improvement, we don't need to change the defaults on
@Endpoint
annotations, as we still want to retain the difference between enablement and exposure; fr example, the"shutdown"
endpoint is not enabled by default.The text was updated successfully, but these errors were encountered: