Search code examples
springspring-cloud-sleuthzipkin

Ignore spans generated by Spring PubSub


I'm using Spring Sleuth starter for a Spring Boot application for tracing calls from external sources. At the same time, the application has a dependency on Spring GCP Starter PubSub for handling events from other services. I checked the last spans generated by the application and found spans from pubsubsubscriberthreadpool (screenshot attached).

An interesting thing here is that I couldn't disable sending spans to Zipkin by adding settings to application.yaml. The settings are:

spring
  zipkin:
    base-url: http://localhost:9411
    service:
      name: notes-api
  sleuth:
    span-filter:
      additional-span-name-patterns-to-ignore: pubsubsubscriberthreadpool
      enabled: true

Adding a regexp-like name for the filter (^pubsubsubscriberthreadpool$) didn't help too.

Are there any solutions to disable such behavior?

spans generated by pubsub's threadpool


Solution

  • I was confused about the span's name because it was not easy to find a source for it. After some research, I found a configuration bean GcpPubSubAutoConfiguration which registers a thread pool for PubSub. And an original name of the thread pool is pubsubSubscriberThreadPool. So in my case, I had to ignore the name of the span considering camelCase.

    The workaround for my case is as follows:

    spring:
      sleuth:
        span-filter:
          additional-span-name-patterns-to-ignore: ^pubsubSubscriberThreadPool$
          enabled: true