We want to propagate Request_id from java mongo driver to MongoDB. Reasons are straightforward, that i want to track everything from start to end. Is there a way or hook exposed somewhere in java mongo driver for this?
Welcome to the community @Rahul_Singh1!
You can use the
comment() option to add a string comment to a
find() query from the Java driver for diagnostic tracing in:
For more information on the server behaviour, see
You might also have a look at command monitoring, which exposes the requestId for every command sent to MongoDB.
@Jeffrey_Yemin:- Thanks for the response. Command monitoring is used to get the request ID, here i am trying to set one before sending the request
@Stennie:- Thanks for the quick response. Can you point me to some examples. Also in our code we are using instances of MongoCollection to do the query and command. It seems there is no option to add comment there.