( DOCUMENTATION )Developer Reference

TraceMole Docs

SDK References/MongoDB Integration

MongoDB Integration

Integrate explain logs within your MongoDB server pipelines.

To collect detailed queries execution stats, wrap your database instrumentation client:

import { withTraceMoleMongo } from "@tracemole/mongodb-wrapper";
import { MongoClient } from "mongodb";

const client = new MongoClient(process.env.MONGODB_URI);
// Instrument the connection client
export const db = withTraceMoleMongo(client.db("production_db"));

The wrapper intercepts find, aggregate, update, and delete actions, tracking underlying query scopes without modifying query outputs or returning payloads.