Skip to content

handleReactive() - Missing TraceId #9110

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

Closed
syedyusufh opened this issue May 3, 2024 · 3 comments
Closed

handleReactive() - Missing TraceId #9110

syedyusufh opened this issue May 3, 2024 · 3 comments

Comments

@syedyusufh
Copy link

.handleReactive() terminal operator does NOT log with traceId / spanId. ReactorContext seems to be lost. This behavior is observed in the latest version 3.2.5 of Spring Boot

Please take a look at the below sample depicting the problem. Thanks

https://github.com/syedyusufh/simple-handle-reactive.git

@syedyusufh syedyusufh added status: waiting-for-triage The issue need to be evaluated and its future decided type: bug labels May 3, 2024
@artembilan artembilan added in: core and removed status: waiting-for-triage The issue need to be evaluated and its future decided labels May 3, 2024
@artembilan artembilan added this to the 6.3.0 milestone May 3, 2024
@artembilan
Copy link
Member

@artembilan
Copy link
Member

Just made the fix and tested it against your sample project.
The result is like this:

2024-05-03T16:04:20.720-04:00  INFO 43564 --- [   scheduling-1] [66354344dbd76e8bec677459a471dd1f-3d269dcbfba2b90c] c.i.s.c.SimpleHandleReactiveFlowConfig   : TraceId is getting printed here
2024-05-03T16:04:20.721-04:00  INFO 43564 --- [   scheduling-1] [66354344dbd76e8bec677459a471dd1f-5ce863f2611f5e8d] c.i.s.c.SimpleHandleReactiveFlowConfig   : Expecting TraceId here
2024-05-03T16:04:21.729-04:00  INFO 43564 --- [   scheduling-1] [663543451b97656ac8a511bd3b44fb61-6fa4a44acb1725b6] c.i.s.c.SimpleHandleReactiveFlowConfig   : TraceId is getting printed here
2024-05-03T16:04:21.730-04:00  INFO 43564 --- [   scheduling-1] [663543451b97656ac8a511bd3b44fb61-84aa2d7e6a70dd6f] c.i.s.c.SimpleHandleReactiveFlowConfig   : Expecting TraceId here
2024-05-03T16:04:22.739-04:00  INFO 43564 --- [   scheduling-1] [66354346274ddcd64a3178df5ff14a88-65c4d06bcb6bed5a] c.i.s.c.SimpleHandleReactiveFlowConfig   : TraceId is getting printed here
2024-05-03T16:04:22.740-04:00  INFO 43564 --- [   scheduling-1] [66354346274ddcd64a3178df5ff14a88-a3808fdfb814b614] c.i.s.c.SimpleHandleReactiveFlowConfig   : Expecting TraceId here

I believe this is what you are expecting.
Thanks

spring-builds pushed a commit that referenced this issue May 3, 2024
Fixes: #9110

* Move context propagation utilities to the `IntegrationReactiveUtils`
* Capture context into message header in the `IntegrationReactiveUtils.adaptSubscribableChannelToPublisher()`
before `sink.tryEmitNext()`
* Restore the context from message header in the `flatMap()` for `ReactiveStreamsConsumer.reactiveMessageHandler`

(cherry picked from commit 7abf1a5)
@syedyusufh
Copy link
Author

Just made the fix and tested it against your sample project. The result is like this:

2024-05-03T16:04:20.720-04:00  INFO 43564 --- [   scheduling-1] [66354344dbd76e8bec677459a471dd1f-3d269dcbfba2b90c] c.i.s.c.SimpleHandleReactiveFlowConfig   : TraceId is getting printed here
2024-05-03T16:04:20.721-04:00  INFO 43564 --- [   scheduling-1] [66354344dbd76e8bec677459a471dd1f-5ce863f2611f5e8d] c.i.s.c.SimpleHandleReactiveFlowConfig   : Expecting TraceId here
2024-05-03T16:04:21.729-04:00  INFO 43564 --- [   scheduling-1] [663543451b97656ac8a511bd3b44fb61-6fa4a44acb1725b6] c.i.s.c.SimpleHandleReactiveFlowConfig   : TraceId is getting printed here
2024-05-03T16:04:21.730-04:00  INFO 43564 --- [   scheduling-1] [663543451b97656ac8a511bd3b44fb61-84aa2d7e6a70dd6f] c.i.s.c.SimpleHandleReactiveFlowConfig   : Expecting TraceId here
2024-05-03T16:04:22.739-04:00  INFO 43564 --- [   scheduling-1] [66354346274ddcd64a3178df5ff14a88-65c4d06bcb6bed5a] c.i.s.c.SimpleHandleReactiveFlowConfig   : TraceId is getting printed here
2024-05-03T16:04:22.740-04:00  INFO 43564 --- [   scheduling-1] [66354346274ddcd64a3178df5ff14a88-a3808fdfb814b614] c.i.s.c.SimpleHandleReactiveFlowConfig   : Expecting TraceId here

I believe this is what you are expecting. Thanks

Thanks, yes it is as expected

artembilan added a commit that referenced this issue May 6, 2024
Related to: #9110

* Make `IntegrationReactiveUtils.CONTEXT_SNAPSHOT_FACTORY` instance conditional on the `IntegrationReactiveUtils.isContextPropagationPresent`
to avoid class-not-found problem for the `io.micrometer.context.ContextSnapshot`
* Make `IntegrationReactiveUtils.captureReactorContext()` & `IntegrationReactiveUtils.setThreadLocalsFromReactorContext()`
 conditional on the `isContextPropagationPresent`

**Auto-cherry-pick to `6.2.x`**
spring-builds pushed a commit that referenced this issue May 6, 2024
Related to: #9110

* Make `IntegrationReactiveUtils.CONTEXT_SNAPSHOT_FACTORY` instance conditional on the `IntegrationReactiveUtils.isContextPropagationPresent`
to avoid class-not-found problem for the `io.micrometer.context.ContextSnapshot`
* Make `IntegrationReactiveUtils.captureReactorContext()` & `IntegrationReactiveUtils.setThreadLocalsFromReactorContext()`
 conditional on the `isContextPropagationPresent`

(cherry picked from commit 2225b83)
EddieChoCho pushed a commit to EddieChoCho/spring-integration that referenced this issue Jun 26, 2024
…Handler`

Fixes: spring-projects#9110

* Move context propagation utilities to the `IntegrationReactiveUtils`
* Capture context into message header in the `IntegrationReactiveUtils.adaptSubscribableChannelToPublisher()`
before `sink.tryEmitNext()`
* Restore the context from message header in the `flatMap()` for `ReactiveStreamsConsumer.reactiveMessageHandler`

**Auto-cherry-pick to `6.2.x`**
EddieChoCho pushed a commit to EddieChoCho/spring-integration that referenced this issue Jun 26, 2024
Related to: spring-projects#9110

* Make `IntegrationReactiveUtils.CONTEXT_SNAPSHOT_FACTORY` instance conditional on the `IntegrationReactiveUtils.isContextPropagationPresent`
to avoid class-not-found problem for the `io.micrometer.context.ContextSnapshot`
* Make `IntegrationReactiveUtils.captureReactorContext()` & `IntegrationReactiveUtils.setThreadLocalsFromReactorContext()`
 conditional on the `isContextPropagationPresent`

**Auto-cherry-pick to `6.2.x`**
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants