Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trace context not available with WebFlux #1143

Closed
jumal opened this issue Nov 24, 2018 · 6 comments
Closed

Trace context not available with WebFlux #1143

jumal opened this issue Nov 24, 2018 · 6 comments
Assignees
Labels
Milestone

Comments

@jumal
Copy link
Contributor

jumal commented Nov 24, 2018

Bug report

The trace context is not always available with WebFlux.

Trying to access propagated extra fields fails due to the unavailability of the trace context in Webflux.

The following code, that used to work with Spring Cloud Finchley and Greenwich M1, does not work anymore with Spring Cloud Greenwich M2 and M3:

  • application.properties
spring.sleuth.propagation-keys=X-Field2
  • Test
    webClient
                .post().uri("/test")
                .contentType(APPLICATION_JSON)
                .accept(APPLICATION_JSON)
                .header("X-Field2", "field2")
                .body(just(entity), TestEntity.class)
                .exchange();
  • Handler
    Mono<ServerResponse> save(ServerRequest request) {
        return request.bodyToMono(TestEntity.class)
                .map(TestEntity::setContext)
                .flatMap(repository::save)
                .flatMap(entity -> ok().build());
    }
  • TestEntity
    TestEntity setContext() {
        field2 = ExtraFieldPropagation.get("X-Field2");
        return this;
    }

ExtraFieldPropagation.get("X-Field2") returns null because the trace context is not available.

@jumal
Copy link
Contributor Author

jumal commented Nov 24, 2018

Added sample project to reproduce the issue: https://github.com/jumal/sleuth-webflux-no-trace-context-issue

@riba2101
Copy link

Hi there,

I've found a similar issue when used in a ReactiveAuthenticationManager with ExtraFieldPropagation.set on a client the context is null and on the server side, ExtraFieldPropagation.get returns null.

ReactiveAuthenticationManager.authenticate calls server and tries to set some fields that should be logged/used on the server side

@anatoliy-balakirev
Copy link

Not exactly the same, but seems to be similar:
#1199

@marcingrzejszczak
Copy link
Contributor

Absolutely. I had a chat with @bsideup and he mentioned that there's a bug in Reactor.

@bsideup
Copy link
Contributor

bsideup commented Jan 28, 2019

@marcingrzejszczak just to clarify:
This is not a bug in Reactor, rather in Sleuth's Reactor integration, but we're working on native trac(k)ing support in Reactor Core (to be used by Sleuth) where the bug should be fixed:
reactor/reactor-core#1481

@marcingrzejszczak
Copy link
Contributor

Ah thanks for the clarification @bsideup. I must have misunderstood you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants