Registry / analytics / mongodb-datadog-stats

mongodb-datadog-stats

JSON →
library0.1.2jsnpmunverified

This package hooks into the MongoDB Node.js driver to automatically record query performance metrics as Datadog histograms. Current stable version is 0.1.2, last updated in 2014. It patches the driver's methods to measure execution time and emit stats to a StatsD client. No longer actively maintained; users are advised to consider alternatives like datadog-metrics or custom APM libraries for modern MongoDB drivers.

npm install mongodb-datadog-stats
INSTALL
IMPORT
SIG · MONGODB-DATADOG-ST
M
mongodb-datadog-stats
analyticsjavascriptv0.1.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (install function)
const mongoDogStats = require('mongodb-datadog-stats');
import mongoDogStats from 'mongodb-datadog-stats';
Package is CommonJS-only; ESM import will fail. Use require().
install function
mongoDogStats.install(mongodb, { statsClient, metric, sampleRate });
new mongoDogStats.install(mongodb, {...});
install is a plain function, not a constructor.
Uninstall function
mongoDogStats.uninstall(mongodb);
Available to remove instrumentation; rarely used but exported.

Instruments the MongoDB driver to send query performance histograms to Datadog via StatsD.

const mongodb = require('mongodb'); const mongoDogStats = require('mongodb-datadog-stats'); const StatsD = require('hot-shots'); // or node-statsd const statsClient = new StatsD({ host: 'localhost', port: 8125 }); mongoDogStats.install(mongodb, { statsClient: statsClient, metric: 'mongodb.query', sampleRate: 0.5 }); // Now all MongoClient operations are instrumented // e.g. db.collection('test').findOne({}, (err, doc) => { // // query time automatically reported to Datadog as histogram // });
Debug
Known issues
breakingRequires mongodb < 3.0 (driver v2.x). Does not work with mongodb >= 3.0 due to major changes in the driver API.
fix
Upgrade to a more recent instrumentation library like 'mongodb-instrumentor' or use Datadog APM.
affects: >=0.1.0
deprecatedPackage is no longer maintained and has not been updated since 2014.
fix
Consider switching to 'datadog-metrics' or 'hot-shots' with manual instrumentation.
affects: >=0.1.0
gotchaPatches the mongodb module globally; calling install() multiple times with different clients may cause unexpected behavior.
fix
Call install() only once per process, passing a single statsClient.
affects: >=0.1.0
gotchaDoes not support promises or async/await; only works with callback-based operations.
fix
Use callback-style or manually wrap with promisify if needed.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'mongodb-datadog-stats'
Package not installed or incorrectly imported in ESM context.
fix
Install via `npm install mongodb-datadog-stats` and use `require()` (CommonJS).
TypeError: mongoDogStats.install is not a function
Using ES6 import statement incorrectly on a CommonJS module.
fix
Use `const mongoDogStats = require('mongodb-datadog-stats');` instead of `import`.
TypeError: Cannot read property 'prototype' of undefined
Passing a newer version of mongodb where the driver's internal structure changed.
fix
Use mongodb driver version 2.x (e.g., `npm install mongodb@2`).
Upgrade
Version history
0.1.2latest on npm
Audit
Dependencies
mongodboptionalPeer dependency: patches the driver's prototype to instrument query methods
Agent activity
18 hits · last 30 days
node
16
OpenAI (training)
1
Resources