feign icon indicating copy to clipboard operation
feign copied to clipboard

Observation KeyValue inconsistency with Spring

Open sunruh opened this issue 1 year ago • 3 comments

Feign-Micrometer supplies observation integration through a Capability, creating an observation with the name http.client.requests, low-cardinality KeyNames are:

  • http.status_code
  • http.method
  • http.url
  • ...

Spring supplies observation integration for other "HTTP clients", like their own RestTemplate and WebClient, with the identical observation name but different KeyNames:

  • status
  • method
  • uri
  • ...

This causes problems in at least the Prometheus instrumentation of Micrometer as the list of KeyNames must be consistent across all regarding meters with the same name.

If they are not, the first one called wins (only it's KeyNames are valid from that point on) and any other observation (that has KeyNames not matching this first set) is being ignored. So when one starts up an application that one time first uses a RestTemplate and on a subsequent start an OpenFeign client, that makes a difference.

Very unsure how this could be solved properly.

  • Changing the KeyNames in feign-micrometer would be a breaking change for anyone relying on the current names and would require maintenance, aligning with further changes on Sping's side
  • Changing the (default) name of the observation would also be a breaking change, as a workaround already possible now as Spring Boot allows overriding the bean definition
  • Fix it in Spring Boot, changing the behavior of Micrometer-Feign completely, possibly rewriting everything there.

sunruh avatar Aug 13 '24 15:08 sunruh

facing the same issue. my solution for now is just renaming feign convention to "feign.http.client.requests"

gxdgodgxd avatar Aug 21 '24 08:08 gxdgodgxd

We (as a temporary fix) created a MeterFilter that converts the tags set by feign-micrometer into the ones that Spring generates.

sunruh avatar Aug 21 '24 10:08 sunruh

As a workaround I created custom convention, which provides same key names like spring for WebClient/RestTemplate

https://gist.github.com/Nazukin-Dmitry/c020cf8c71adccde7186a89e5bad7989

Nazukin-Dmitry avatar Sep 11 '24 12:09 Nazukin-Dmitry