Pass CorrelationId during mongo queries and commands

I’m looking for a way to make reviewing the Atlas Profiler more useful by adding a CorrelationId to my collection queries. I’d like to be able to do something like this (using python):

db[“my_collection”].find({}, corr_id=“some_guid”)

Then, when looking at the profiler I’d like to be able to see this correlationId in the log:

{ "type": "command", "ns": "steel_command.inventory_props_cache", **"correlation_id": "some_id",** "command": { "getMore": 7276652552318456000, "collection": "inventory_props_cache", "lsid": { "id": { "$binary": { "base64": "G+3BvDN4SSif58z5vhG/sw==", "subType": "04" } }

Is there something like this already built into Mongo to allow us to more easily correlate a mongo log to an application-level event?

Thank you!
Matt

1 Like

Hi @Matt_Jones2 and welcome in the MongoDB Community :muscle: !

To be honest this feature doesn’t ring a bell here. Maybe I missed it but it never reached my ears.

You could submit this idea in the feedback engine if it’s not already suggested. :slight_smile:

https://feedback.mongodb.com/

Cheers,
Maxime.