Custom Transaction and MongoDB Spans

(Henrique Marques Fernandes) #1


I started integrating my project with the nodejs agent, which is f* awesome by the way, it's working perfect with my express routes, giving me all the database action inside it and everything... Now i'm trying to make a custom transaction to monitor my tasks (RabbitMQ), got it working smoothly but now I'm wondering if there is any way i can track my mongo queries inside this custom transaction like in express.


(Thomas Watson) #2

Glad to hear you like the Node.js agent :blush:

As such, there's no technical difference between the transactions we start automatically when we detect an incoming HTTP request, and custom transactions you start manually. Any database query that happens during a transaction should automatically be recorded as a span and associated with the parent transaction like you see during the Express routes.

There can be a couple of reason why you don't see any database spans for your RabbitMQ tasks, but my main suspicion is that RabbitMQ (or some related dependency) is built in a way so the agent can't automatically follow the async call-stack.

It's common that database drivers etc. implement their own callback queue instead of relying on the event-loop. If so, when a callback is called, the agent can't know which transaction was active when that callback was queued. In these cases, we need to patch the offending node module so it can be properly instrumented.

To better understand what's going on in your case, could I get you to enable debug mode and have your app try to process a task from RabbitMQ that involves a MongoDB query and then send us the resulting log (be sure to scrub any potentially sensitive or personally identifiable information from the logs before sending).


(Henrique Marques Fernandes) #3

Hi Thomas,

Thanks for the quick response!

I enabled the debug mode and saw the transaction was intercepting the mongo buuut then I realized I wasn't waiting my db to finish the query. Don't hate me! hahahahaha

Thank you very much!

(system) #4

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.