0

I have Spring Cloud Sleuth (2.0.2.RELEASE) working within a (partially) reactive class in some web based request/response system. The code is something like this:

private static final Scheduler PROCESSING_SCHEDULER = Schedulers.newParallel("processingScheduler");

public Set<ProcessedItem> processItems(List<Item> incomingItems) {
    return Flux.fromIterable(incomingItems)
        .publishOn(PROCESSING_SCHEDULER)
        .collectMultimap(Item::getRequestIdentifier)
        .flatMapIterable(Map::values)
        .flatMap(itemProcessor::processGroupedItems)
        .collect(Collectors.toSet())
        .block();
}

As there are quite many responses coming in all the time, this method is being called several hundreds of times for one single request. I suspect that this call with the .publishOn leads to hundreds and thousands of async spans in Zipkin (see attached screenshot). At least I assume that the spans are from that because it is what I understand from the documentation

So my first question would be: How can I associate a name for such async threads? I don't have a place to put @SpanName here.

As a follow up, is there any way to NOT collect these spans? I don't need them, they fill up our Zipkin storage, but I also don't want to disable reactive or Sleuth in general since it is needed in other places ...

Screenshot from Zipkin

Dominik Sandjaja
  • 6,326
  • 6
  • 52
  • 77

1 Answers1

1

You can create your own custom SpanAdjuster that will modify the span name. You can also use FinishedSpanHandler to operate on finished spans to tweak them.

Marcin Grzejszczak
  • 10,624
  • 1
  • 16
  • 32