spring-webfluxspring-cloud-gatewayspring-cloud-sleuthreactor-nettyzipkin

Spring cloud sleuth with spring cloud gateway


I'm using spring cloud sleuth with spring cloud gateway (webflux based) I would like to only "log" TraceId and SpanId without propagating in http request

Given this scenario :

client --> cloud gateway --> target_uri

I dont want to add X-B3-* (and other custom fields) to the http request going towards target uri. I ONLY want to log (for now) these informations, and I was able to do it without problems. Is there an option ? I've to customise something ?

Thanks in advance


Solution

  • You can disable the integration between Sleuth and Feign with the property

    spring.sleuth.feign.enabled = false
    

    You can read more about this on the docs from Sleuth - OpenFeign Integration.

    Bear in mind that Sleuth doesn't have a way to disable the header injection based on an endpoint, so this is an all on / off switch. This is a problem if you have another service and want to send the trace headers to the other service, but not to services outside your control.

    Edit

    Since you are using netty, you have to set this flag:

    spring.sleuth.web.client.enabled = false
    

    There's more info in the docs