Spring Boot configures http clients (resttemplate & webclient) by default to gather metrics using micrometer.
We use the property management.metrics.enable.http.client.requests to disable http client request metrics by default but under the hood micrometer Meter.Id instances are still being created for every permutation of tags measured.
Given enough permutations this can create something close to a memoryleak as it will create (and cache) all these Meter.Ids and cause severe pressure on GC or even apps dying due to an OOME.
as a workaround we can set management.metrics.web.client.request.autotime.enabled to false but I would expect this to be disabled automatically when http client request metrics are disabled.
This is on Spring boot 2.7.3
Comment From: wilkinsona
The management.metrics.enable property is described as "whether to prevent meters from emitting any metrics". As such, the behavior that you have observed is to be expected – the meters for HTTP client requests are still created but no metrics are emitted from them.
To disable auto-timing of client request metrics, you should set management.metrics.web.client.request.autotime.enabled to false as you have done. Alternatively, you can exclude HttpClientMetricsAutoConfiguration entirely.
Comment From: breun
Based on the description of the property me and my colleagues expected no meters would be created with management.metrics.enable set to false. It was only after they investigated out-of-memory issues that they discovered that lots of meter objects were still being created.
Maybe we could expand the property description to make it explicit that it affects emitting metrics, but doesn’t affect creation of meters? And maybe add a reference to management.metrics.web.client.request.autotime.enabled for the latter? We could create a PR for this.
Comment From: wilkinsona
Thanks, @breun. I hadn't noticed that management.metrics.web.client.request.autotime.enabled is only mentioned in the appendix. I've added something about it to the main section on HTTP client metrics and tried to clarify the filtering behavior in https://github.com/spring-projects/spring-boot/commit/7d983be769826c0d141129a419d56d9a765d7fc2.