Skip to content

Tracer.activeSpan() returning null if Spring Cloud Gateway is present #1807

@blake-bauman

Description

@blake-bauman

Description

After updating from Release Train 2020.0.0-M4 to 2020.0.0-M6, Tracer.activeSpan() is returning null if Spring Cloud Gateway is present. Issue is still present in RC1. It's as if OpenTracing isn't configured properly with the latest 2020.0.0 release and Spring Cloud Gateway. My guess is it has to do with #1757 breaking SCG integration?

If I revert to M4 or a Hoxton release, it works. If I remove Spring Cloud Gateway, it works (but of course, my routes no longer work).

Sample

I've created a sample project which demonstrates the problem here: https://github.com/blake-bauman/test-spring-cloud-sleuth-gateway

With SCG dependency included, the result is null, but remove the dependency and you get an active Span.

For reference, the application is:

@SpringBootApplication
public class DemoApplication {

    public static void main(final String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

@Bean
    public RouterFunction<ServerResponse> helloWorld(final WebClient.Builder builder, final Tracer tracer) {
        return route(GET("/hello"), request -> Mono.fromCallable(() -> "Active Span is " + tracer.activeSpan())
                                                   .flatMap(result -> ServerResponse.ok().contentType(TEXT_PLAIN).body(fromValue(result))));
    }
}

In our real project, we've also hooked up the trace data to the logging, and the trace data is also missing from the logs with SCG included. Without SCG, it shows up.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions