-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Observability: Gateway client requests clash with WebClient request metrics #3153
Comments
@jonatan-ivanov @shakuzen, should we make this workaround permanent? |
The Prometheus Java client does, the Prometheus Server must be ok with this since multiple apps can ship metrics with the same name but different labels, the missing labels are handled as Do you use
This should be easy:
@spencergibb Permanently fixing this should be easy, it's just modifying this hardcoded value: Line 75 in 43eb8ce
But there are some consequences: it is a breaking change that can break people's dashboards and automation since the name of the Observation and everything that is created from that Observation will have a different name. So I would like to understand the use case behind using WebClient in Gateway first. If it seems to impact lot of people maybe changing this in the next release is something we should consider, otherwise I would document it. |
@jonatan-ivanov thank you for the explanation and detailed feedback.
You're correct, that is the way we're currently solving the issue
Indeed we use the WebClient in the Gateway. In our case it is a necessity because we're not in control of certain authentication mechanisms, we're forced to validate certain values with an external server. This leads to the usage of WebClient in Gateway.
This is correct for all Gateway set-ups based on version 4.x or higher. This was a breaking change in upgrade to 4.x as well though coming from 3.x Gateway versions. |
We just upgraded to Boot 3.4.0 and Cloud 2024.0.0 and became aware of this issue due to the following warning now being logged:
We also use |
We should make it configurable |
I noticed that there also is a |
We're also facing this issue after upgrading to Spring Boot 3.4.1 and Spring Cloud 2024.0. The workaround mentioned by @kkondratov worked for us too. Has there been any update or progress on a permanent fix? |
Describe the bug
After upgrading to spring boot 3 with gateway 4.0.6 we've noticed that our metrics for the webclient are not available anymore in prometheus
With the use of micrometer observability an introduction was done to provide the
http.client.request
metrics for the gateway client.This clashes with the default
http.client.request
provided by theDefaultClientRequestObservationConvention
from spring-web.This was introduced in: https://github.com/spring-cloud/spring-cloud-gateway/pull/2715/files
The prometheus
lowCardinalityValues
defined inGatewayDocumentedObservation
differ from the ones defined in theClientHttpObservationDocumentation
. GatewayDocumentedObservation has for examplehttp.method
,http.status_code
and the ClientHttpObservationDocumentation hasmethod
,uri
,status
This causes the metric
http.client.requests
be reported with different labels, ones for the Gateway WebClient metrics and one for the Spring Web configured one.Prometheus unfortunately ignores metrics if a metric is encountered with different labels than the initially scraped ones, for context:
Ideally spring cloud client request metrics should have the prefix
spring.cloud.gateway
for the DefaultGatewayObservationConvention.Its not easy to override this property either since the values are reference by the singleton instance. Only two approaches currently are: shadow the
ObservedRequestHttpHeadersFilter
and theDefaultGatewayObservationConvention
or disable observability which is not desirable.EDIT
Looks like overriding the bean
DefaultGatewayObservationConvention
and overriding the name works as a workaround:The text was updated successfully, but these errors were encountered: