Skip to content

How to propagate Context to reactive/coroutine MongoDB commands? #9866

Answered by laurit
glebignatieff asked this question in Q&A

You must be logged in to vote

You might have better luck with java agent. As you noticed the context is lost before TracingCommandListener to make it work we'd need to figure out how to get the context there. I think the context is lost in https://github.com/mongodb/mongo-java-driver/blob/02a61642394ca707beb30947101afb5b8c6d36b7/driver-core/src/main/com/mongodb/internal/connection/DefaultConnectionPool.java#L1286 in java agent we can wrap the task object and use that to preserve the context but for library instrumentation our options are much more limited. One option to make it work would be to rewrite the instrumentation in a different way. Instead of using TracingCommandListener one could attempt to wrap the mongo r…

Replies: 1 comment 1 reply

You must be logged in to vote
1 reply
@glebignatieff

Answer selected by glebignatieff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants