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

No tracing context when processing ClientResponse body #31817

Closed
norbson opened this issue Dec 12, 2023 · 7 comments
Closed

No tracing context when processing ClientResponse body #31817

norbson opened this issue Dec 12, 2023 · 7 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: duplicate A duplicate of another issue

Comments

@norbson
Copy link

norbson commented Dec 12, 2023

When processing ClientResponse body, tracing context is missing.

One of many way to reproduce it:

clientResponse.mutate().body(dataBuffer -> dataBuffer.doOnNext(db -> log.info("No tracing here")))

Environment:

  • Spring Boot 3.1.5
  • Spring Framework: 6.0.13
  • Project Reactor 3.5.11
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Dec 12, 2023
@bclozel
Copy link
Member

bclozel commented Dec 14, 2023

org.springframework.web.reactive.function.client.ClientResponse#mutate returns a Builder type which is not reactive. The Flux given as an argument is merely a transformation function and there is no observation attached in the reactor context there. In my opinion this is working as designed. I'm no sure which observation context you would expect there.

I'm closing this issue for now. If you still think there is a bug, a sample project showing the actual use case and explaining what behavior is expected would be useful.

@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Dec 14, 2023
@bclozel bclozel added in: web Issues in web modules (web, webmvc, webflux, websocket) status: invalid An issue that we don't feel is valid and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Dec 14, 2023
@norbson
Copy link
Author

norbson commented Dec 15, 2023

Sample project
https://github.com/norbson/sb-tracing

As You see on below screen, when processing response body stream, tracing is lost.

We wiretap on response body (Flux<DataBuffer>) for generic logging purpose.

Similarly, we wiretap on request body but there is no problem with tracing.

image

@norbson
Copy link
Author

norbson commented Dec 15, 2023

Even more obvious case with Flux.

Code:
https://github.com/norbson/sb-tracing/tree/flux

In this case tracing context is missing also later in the chain, when processing already decoded element.

image

@norbson
Copy link
Author

norbson commented Dec 15, 2023

In summary, I believe that restoring threadLocal failed in these cases.

@bclozel
Copy link
Member

bclozel commented Dec 15, 2023

I've been having a look and I'm not sure at this stage if this is a bug in Spring Framework, in Reactor or an expected behavior given the decoder setup.

I'm seeing that the context is not being established in the tokens.handle part of the AbstractJackson2Decoder#decode. I'll need some more time to pinpoint where the context is "lost" and whether we can do something about it.

@bclozel bclozel reopened this Dec 15, 2023
@bclozel bclozel added status: waiting-for-triage An issue we've not yet triaged or decided on and removed status: invalid An issue that we don't feel is valid labels Dec 15, 2023
@bclozel bclozel self-assigned this Dec 15, 2023
@bclozel
Copy link
Member

bclozel commented Dec 15, 2023

After chatting with the reactor team (thanks a lot @chemicL !), this is actually another instance of #30273. This is a complex issue that was fixed in Reactor 3.6 (see the dedicated reactor announcement blog post).

I've upgraded your sample to Spring Boot 3.2 and it all works fine. This is a major feature in Reactor and will not be backported to previous generations.

I'm closing this issue as a result. Thanks for the report!

@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Dec 15, 2023
@bclozel bclozel added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Dec 15, 2023
@norbson
Copy link
Author

norbson commented Dec 15, 2023

Thank you for your time and help! And sorry for incomplete description at first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants