2

I'm working on an app that uses Spring Sleuth and Feign to propagate headers between incoming and outgoing rest requests automatically. We want to restrict this blanket behaviour (as headers are forwarded on all downstream calls) and remove a specific header from one call.

I'm wondering if spring provides this flexibility. I saw there's an similar question but cannot understand the solution and looking around the Sleuth documentation and code I cannot find an option to do this.

Augusto
  • 28,839
  • 5
  • 58
  • 88

1 Answers1

1

The docs has a section called OpenFeign, it tells you how to enable/disable instrumentation for Feign and/or for your custom Feign components, see: spring.sleuth.feign.enabled and spring.sleuth.feign.processor.enabled.

As far as I know, there is no config option to disable this by URL, you can try two things:

  1. You can inject an interceptor to your http client that removes the headers
  2. You can open an issue for Sleuth to add an enable flag per feign client so that you can turn instrumentation on for one client and off for another one
Jonatan Ivanov
  • 4,895
  • 2
  • 15
  • 30
  • Thanks Jonatan! I looked at the documentation before and also couldn't see a solution. I'm thinking of ditching Spring for good as it brings more trouble (and unexpected behaviours) in favour of something simpler. (Edit: No offense, I just saw you work for Spring) – Augusto Nov 01 '21 at 17:58
  • Yeah, I work on Spring Cloud Sleuth so I might be biased and definitely see this from a different perspective but one of the goals of Spring is making things simpler for the users. If you can share some feedback about why does it mean more trouble (and unexpected behaviours) for you, please do so in an issue, we are always looking for getting feedback from our users. Regarding your original issue here, would any of my proposals above work for you? – Jonatan Ivanov Nov 01 '21 at 18:08
  • Thanks for the suggestions @Jonatan Ivanov. I think the problem is that we are using Sleuth to forward tracing headers and other unrelated headers ... but these other headers should be handled manually or in a different way rather than using Sleuth because it happens to have a feature to forward headers. The 2nd option might be a solution... the 1st one has the potential of making the expected behaviour of the application more obscure as it wouldn't be obvious why some headers are forwarded and other are not in some circumstances. Thanks once more! – Augusto Nov 01 '21 at 19:55