Automatically Trace MongoDB Calls from AWS Lambda

Maurice Rickard
IOpipe Blog
Published in
2 min readOct 15, 2019

--

Debugging your MongoDB and AWS Lambda integrations with new Auto-Tracing Update from IOpipe

If you’re using AWS Lambda to send commands to MongoDB Atlas (or considering it), IOpipe recently added MongoDB auto-tracing to help developers gain real-time visibility and faster debugging for their database queries.

One of the biggest challenges for developers and engineering teams building serverless applications on AWS Lambda is gaining whole event observability — particularly when it pertains to functions that make calls outside of the AWS ecosystem.

The new feature empowers users to trace many MongoDB commands automatically and provide real-time invocation metrics, including duration and connection information.

For current IOpipe users, enabling auto-tracing is a simple as setting the environment variable IOPIPE_TRACE_MONGODB to true. See below for the full instructions.

For non-IOpipe users, sign up for your free tier or trial and use your preferred install method, including our blazing-fast, no-code setup via our Serverless Plugin.

Auto-tracing MongoDB Instructions:

Set the environment variable IOPIPE_TRACE_MONGODB to true, and IOpipe will trace commands automatically: which command, which key is being read or written, database and collection name (if available), and the connection’s hostname and port. This plugin supports these commands:

  • command, insert, update, and remove on the Server class
  • connect, close, and db on the MongoClient class.
  • find, findOne, insertOne, insertMany, updateOne, updateMany, replaceOne, deleteOne, deleteMany, createIndex on collections. bulkWrite is also supported, and generates a list of which commands were part of the bulk operation.
  • next, filter, sort, hint, and toArray on the Cursor class.

Commands used with a callback parameter generate end traces and duration metrics. (Note that MongoDB commands that don’t take callback params — like find — won’t generate durations.)

This plugin supports MongoDB Node.JS Driver v3.3 and newer. (This includes the latest version of Mongoose, which uses the native v3.3 driver.)

Help and Feedback

If having trouble with the auto-tracing MongoDB commands, please reach out to our team via community Slack or email. We’d love to get your feedback and assist you with any difficulties.

About IOpipe

As the leader in serverless dev tooling for monitoring and observability, IOpipe offers real-time visibility into the most granular behaviors of today’s serverless applications on AWS Lambda.

Founded in 2016 by Erica Windisch and Adam Johnson, IOpipe reduces debugging time from hours to seconds, delivers transparent insights into the behaviors and performance of your serverless functions, and reduces risk for enterprises shifting to serverless.

Working with global brands like Matson, Rackspace, and APM Music, IOpipe empowers engineering teams to deliver with confidence, debug intelligently, and get busy building the impossible.

In other words, IOpipe makes it a lot more fun to be a developer. Visit www.iopipe.com to learn more and try it for free.

--

--