Affects: 6.0.3
Problem Description
Ever since Spring Framework 6, the client.name
tag from http.client.requests
metrics are missing.
Steps to Reproduce
- Create a Spring Boot 3.0 application (which comes with Spring Framework 6)
- Add
spring-boot-starter-actuator
andspring-boot-starter-web
dependencies - Run a task that periodically send requests to external endpoint using
RestTemplate
- Visit
/actuator/metrics/http.client.requests
endpoint and observe that theclient.name
tag is missing
Sanity Check
- Create a Spring Boot 2.7.6 application (which comes with Spring Framework 5)
- Add
spring-boot-starter-actuator
andspring-boot-starter-web
dependencies - Run a task that periodically send requests to external endpoint using
RestTemplate
- Visit
/actuator/metrics/http.client.requests
endpoint and observe that theclient.name
tag is present
I've created a repository to help in reproducing the issue. Check out https://github.com/mchin7/actuator-missing-tag-demo
Sorry if this is issue is not a Spring Framework issue, any redirection to the correct project is highly appreciated!
Comment From: bclozel
The "client.name"
is contributed by the client observation as a high cardinality KeyValue
, as we can't guarantee that the value is bounded for the application. As a result, this metadata ships with traces, but not metrics right now.
We consider moving it back to a low cardinality KeyValue
if we believe that it's highly unlikely that an application queries enough different hosts to make the metrics system fail. As far as I remember, we did not configure a MeterFilter
for this tag in Spring Boot 2.x to avoid cardinality explosion.
Changing it back to a low cardinality would not break applications as the value would be still present in traces, but would add it back into metrics. WDYT @marcingrzejszczak ?
Comment From: jonatan-ivanov
FWIW, I think this should be a low cardinality key-value normally. Those users who has apps with lots of http clients in them (still low cardinality) but want to lower the number of time series they have, they can add a MeterFilter
.
Comment From: mchin7
Thank you so much for the prompt response and the detailed explanation on the issue.
For folks facing the same issue and are unable to revert to earlier version, a workaround is to simply overrides the DefaultClientRequestObservationConvention#getLowCardinalityKeyValues
to also return the client.name
tag by calling clientName(context)
method.
Then, simply register it as a bean in Spring context and it should be picked up.
See example here https://github.com/mchin7/actuator-missing-tag-demo/commit/f0414a4c83b1ea01995a8377c64f3b96c7a43bdb