-
Notifications
You must be signed in to change notification settings - Fork 40.8k
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
Management endpoints are created even though they are disabled #2921
Comments
I guess that option meant "exposure" as REST or MBean endpoints but it'd probably more consistent to use that property to create the service at all. Other things should nicely fit in (with the exposure part being conditional of the presence of the service itself). There is a |
I'd agree. The one thing that really needs to be reviewed is that the endpoints registered via But again the
|
The mismatch in the handling of enabled was introduced by me as part of the fix for #2767. The bug was MVC specific and I neglected to consider the JMX/general side of things. |
👍 For what it's worth, I also would like to see the endpoints not created at all if they are disabled as an enhancement. |
I think it's useful (and generally harmless) to have the JMX end points even if the MVC ones are disabled. |
My point is if JMX is disabled/ not used at all and the endpoint is disabled (requests are traced differently in this application), I don't need to have all these |
I guess if you feel strongly about a particular endpoint, e.g. you don't want traces, you just need to exclude from your |
Yes, /**
* Make the capacity of the {@link TraceRepository} configurable. This determines how many requests are kept under /management/trace
* @param capacity the capacity of the trace repository
* @return the configured TraceRepository
*/
@ConditionalOnProperty(value = "endpoints.trace.enabled", havingValue = "true", matchIfMissing = true)
@Bean
public TraceRepository traceRepository(@Value("${management.trace.capacity:10}") int capacity) {
Assert.isTrue(capacity > 0, "management.trace.capacity must be > 0");
Assert.isTrue(capacity < 500, "management.trace.capacity must be < 500");
InMemoryTraceRepository inMemoryTraceRepository = new InMemoryTraceRepository();
inMemoryTraceRepository.setCapacity(capacity);
return inMemoryTraceRepository;
}
@ConditionalOnProperty(value = "endpoints.trace.enabled", havingValue = "true", matchIfMissing = true)
@Bean
public WebRequestTraceFilter webRequestLoggingFilter(BeanFactory factory, TraceRepository traceRepository, @Value("${management.dump_requests:false}") boolean dumpRequests) {
WebRequestTraceFilter filter = new WebRequestTraceFilter(traceRepository);
filter.setDumpRequests(dumpRequests);
if (factory.containsBean("errorAttributes") && factory.isTypeMatch("errorAttributes", ErrorAttributes.class)) {
filter.setErrorAttributes(factory.getBean(ErrorAttributes.class));
}
return filter;
} I have to admit though that this doesn't consider whether JMX is enabled or not at the moment. |
Alex, please let's not mix the disable/enable debate with the ability to customize an endpoint. As I already asked previously, please open a separate thread for that one as it's clearly unrelated (unless I misunderstood something?). Looking at your original description again, I feel that the issue you're having has nothing to do with that. If you want to control the Indeed we're not exposing everything as properties as we would like to avoid the PDD effect (Properties Driven Development). What about the following for your use case? @Configuration
public class SomeConfigOfYours {
@Bean
public TraceRepository traceRepository(@Value("${trace.repository.capacity}") int capacity) {
InMemoryTraceRepository repo = new InMemoryTraceRepository();
repo.setCapacity(capacity);
return repo;
}
} Only one |
I don't think you're missing something, it might just be that we talk past each other. The above snippet is from a The main point was that we had the requirement to introduce a way to disable the collection of the @ConditionalOnProperty(value = "endpoints.trace.enabled", havingValue = "true", matchIfMissing = true) So, there 2 issues that I worked around in the above mentioned solution
Does that make sense? |
Does it make sense to at least add My use case is that I'm currently developing high load app and don't want to trace each and every call with built-in functionality (I use different mechanisms for that). I also do not want that my app creates objects which are not used. However to disable it completely I have to inherit from this filter and override protected boolean shouldNotFilter(HttpServletRequest request) throws ServletException {
return true;
} I would be glad to have a way to do it via configuration, as it was already discussed in this thread. |
@PostalBear You could just exclude the configuration: @SpringBootApplication(exclude=TraceWebFilterAutoConfiguration.class) |
Though Spring Boot provides the configuration property to disable certain management endpoints, all of them are instantiated no matter whether they are enabled or disabled via configuration. Especially looking at the
TraceEndpoint
which holds an instance ofTraceRepository
which again references objects representing the last 100 HTTP requests, we seem to be looking at memory hogs here.A very naive idea to avoid this would be something like this (from
org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration
)but I'm not sure about the side effects this might introduce. And this doesn't prevent the
TraceRepository
and theWebRequestTraceFilter
from being instantiated.The text was updated successfully, but these errors were encountered: