Skip to content

Rename gateway client observation metric to avoid WebClient conflict#4153

Open
LivingLikeKrillin wants to merge 4 commits into
spring-cloud:mainfrom
LivingLikeKrillin:fix/gateway-observation-name-conflict
Open

Rename gateway client observation metric to avoid WebClient conflict#4153
LivingLikeKrillin wants to merge 4 commits into
spring-cloud:mainfrom
LivingLikeKrillin:fix/gateway-observation-name-conflict

Conversation

@LivingLikeKrillin
Copy link
Copy Markdown

Gateway and Spring Web's DefaultClientRequestObservationConvention both
publish under http.client.requests but emit different low-cardinality
label sets, so a Prometheus registry refuses to register one of them
and a metric series is silently dropped. Spring Boot 3.4+ logs this
as a meter registration failure.

Rename the gateway client observation to spring.cloud.gateway.http.client.requests
so it can coexist with WebClient's metric. The .active LongTaskTimer
variant follows automatically.

This is a breaking change for dashboards, alerts, and queries
referencing the old metric name. Users who already customize the
convention via a GatewayObservationConvention bean are unaffected.

Fixes gh-3153

@LivingLikeKrillin LivingLikeKrillin force-pushed the fix/gateway-observation-name-conflict branch 2 times, most recently from 4bc48e8 to 775f910 Compare May 8, 2026 16:38
Renames DefaultGatewayObservationConvention's metric from
'http.client.requests' to 'spring.cloud.gateway.http.client.requests'
so it no longer collides with Spring Web's
DefaultClientRequestObservationConvention, which uses the same name
with a different low-cardinality label set and causes Prometheus to
drop one of the two series.

Fixes spring-cloudgh-3153

Signed-off-by: Jooyoung Jung <143606756+LivingLikeKrillin@users.noreply.github.com>
Explains on DefaultGatewayObservationConvention#getName() why the
metric is prefixed with 'spring.cloud.gateway.' so a future reader
does not revert the rename without understanding the Prometheus
collision it avoids.

See spring-cloudgh-3153

Signed-off-by: Jooyoung Jung <143606756+LivingLikeKrillin@users.noreply.github.com>
Adds focused unit assertions for the gateway client observation convention
beyond the metric name renamed in the previous commit:

- guard that getName() does not equal Spring Web's http.client.requests
- getContextualName span naming
- low-cardinality key set (http.method, http.status_code, and both
  spring.cloud.gateway.route.* keys)

Previously only covered indirectly by the integration-style
ObservedHttpHeadersFilterTests.

See spring-cloudgh-3153

Signed-off-by: Jooyoung Jung <143606756+LivingLikeKrillin@users.noreply.github.com>
Regenerated by micrometer-docs-generator after the gateway client
observation metric rename in the previous commits. No hand edits.

See spring-cloudgh-3153

Signed-off-by: Jooyoung Jung <143606756+LivingLikeKrillin@users.noreply.github.com>
@LivingLikeKrillin LivingLikeKrillin force-pushed the fix/gateway-observation-name-conflict branch from 775f910 to d6fb917 Compare May 8, 2026 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Observability: Gateway client requests clash with WebClient request metrics

2 participants