title: How to trace Mongoose query execution time
body: <p>I'm trying to create trace spans of my node.js with Mongoose application. One specific trace I would like to get is how long one Mongoose query, update or document.save method takes time.</p>
  
  <p>What I know is that Mongoose has pre and post hooks for these methods: <a href="https://mongoosejs.com/docs/middleware.html" rel="nofollow noreferrer">https://mongoosejs.com/docs/middleware.html</a></p>
  
  <p>However I'm struggling to find a good example how to keep timer in context between the hooks so that I get the trace of one and the same operation execution. Is there a good way to accomplish this?</p>