spring-cloud / spring-cloud-sleuth

Distributed tracing for spring cloud
https://spring.io/projects/spring-cloud-sleuth
Apache License 2.0
1.78k stars 782 forks source link

spring.zipkin.discoveryClientEnabled ignored when the traced app is webflux #2339

Closed codefromthecrypt closed 9 months ago

codefromthecrypt commented 9 months ago

Describe the bug

Documentation says to use spring.zipkin.discoveryClientEnabled to report spans to Zipkin discovered (likely in Eureka). Technically, ZipkinUrlExtractor will do the work, to subsitute the application name encoded as the hostname in spring.zipkin.baseUrl for a usable instance.

However, if ConditionalOnWebApplication.Type.REACTIVE triggers, then none of this happens and reporting to zipkin fails, as the fake hostname wasn't substituted.

Sample

Make an app like this and it triggers reactive reporting.. Since the async reporter buffers actual work from the production requests, onto a separate thread, there really should be no reason to restrict Eureka depending on which frontend is in use.

  @GetMapping("/api")
  public Mono<String> printDate(@RequestHeader("user_name") Optional<String> username) {
    return Mono.fromSupplier(() -> {
      String date = LocalDate.now().toString();
      return username.map(u -> date + " " + u).orElse(date);
    });
  }
codefromthecrypt commented 9 months ago

thanks and verified manually and going forward automatically that this works. Thanks @marcingrzejszczak! https://github.com/openzipkin/brave-example/pull/113