Search code examples
spring-cloud-sleuth

Spring Cloud Sleuth - disable sampling in distributed system


As per Spring Cloud Sleuth span Sampling we can control sampling rate.

Samplers do not stop span (correlation) ids from being generated, but they do prevent the tags and events being attached and exported. By default you get a strategy that continues to trace if a span is already active, but new ones are always marked as non-exportable.

To reduse performance bottlenack, Can we disable span ids generation in deployment instance at runtime without restarting application?


Solution

  • In Edgware, the sampler bean is using @RefreshScope so you can, at runtime, change the sampling percentage. However, I don't know if that's exactly what you're asking for. Most likely you're asking about disabling Sleuth at all at runtime. That's unfortunately not possible by default. What you can do however is register a custom Random bean that can be @RefreshScoped and that will generate a fixed ID when required.