Search code examples
spring-bootzipkinspring-cloud-sleuthspring-cloud-consul

How to prevent sleuth / zipkin to trace catalog-services-watch?


I've enabled zipkin on my application and it works fine, I see the traces. My application is using Consul service discovery, and I see a lot of traffic being traced in Zipkin.

Traces are like have names like "catalog-services_watch" and contain things like :

{
  "key": "class",
  "value": "ConsulCatalogWatch",
  "endpoint": {
    "serviceName": "myService",
    "ipv4": "10.0.36.114",
    "port": 8443
  }
},
{
  "key": "lc",
  "value": "scheduled",
  "endpoint": {
    "serviceName": "myService",
    "ipv4": "10.0.36.114",
    "port": 8443
  }
},
{
  "key": "method",
  "value": "catalogServicesWatch",
  "endpoint": {
    "serviceName": "myService",
    "ipv4": "10.0.36.114",
    "port": 8443
  }
}

How can I disable these traces ? I've tried the spring.sleuth.instrument.web.skipPattern parameter, but it's not working.


Solution

  • I found that these traces are actually generated by https://github.com/spring-cloud/spring-cloud-consul/blob/master/spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/discovery/ConsulCatalogWatch.java

    And since this is a class annotated with @scheduled , this Sleuth aspect applies :

    https://github.com/spring-cloud/spring-cloud-sleuth/blob/master/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/scheduling/TraceSchedulingAspect.java

    And therefore, the property to control the skipped regexp is not spring.sleuth.instrument.web.skipPattern , but spring.sleuth.instrument.scheduled.skip-pattern