Skip to content

Risto-Stevcev/statsd-mongoose

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

statsd-mongoose

Build Status Coverage Status

📈 A statsd client for mongoose

Usage

const mongoose       = require('mongoose')
    , statsdMongoose = require('statsd-mongoose')

mongoose.connect('mongodb://some.mongo.uri:1234/db-name')
mongoose.plugin(statsdMongoose)

Options

host - The statsd hostname (default: 'localhost')
post - The statsd port (default: 8125)
ns - The function that gets called to generate the namespace. It binds this from the mongoose pre and post middleware, and passes in the model and method names as parameters. (default: (model, method) => `db.${model.toLowerCase()}.${method}` )

How It Works

The plugin uses the statsd lynx client to create timer metrics with mongoose pre and post middleware to record start/finish times. Metrics are namespaced as db.[collection-name].[method-name]. See the docs for more info.

License

Licensed under the MIT license.