Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/restorando/monolith
`statsd` client wrapper and `express` middleware
https://github.com/restorando/monolith
express expressjs middleware statsd
Last synced: 2 months ago
JSON representation
`statsd` client wrapper and `express` middleware
- Host: GitHub
- URL: https://github.com/restorando/monolith
- Owner: restorando
- Created: 2016-09-01T19:12:11.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-04-20T16:07:05.000Z (over 7 years ago)
- Last Synced: 2024-10-09T18:15:31.909Z (3 months ago)
- Topics: express, expressjs, middleware, statsd
- Language: JavaScript
- Homepage:
- Size: 9.77 KB
- Stars: 4
- Watchers: 20
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Monolith
Express middleware for your log-to-`statsd` needs.## Installation
```
npm install --save redo-monolith
```## Usage
```js
var monolith = require('redo-monolith');
var statsd = monolith({
host: '127.0.0.1',
port: 8125,
queueHeader: 'X-Request-Start'
});
```### As an `express` middleware
```js
var express = require('express');
var app = express();function sendFn(params) {
/**
* `params` is an object with the following attributes for logging what you want about the request:
* queueDuration: amount of time since the request has been enqueued by `nginx` until the request finishes
* requestDuration: amount of time since the request started to be processed by `express` until it finishes
* status: a `String` representation of the resulting HTTP status code
* req: an `express#Request` object
* res: an `express#Response` object
* client: a `lynx` instance
*/params.client.increment(params.status);
}app.use(statsd.middleware({ send: sendFn }))
```### As a standalone statsd client
```js
statsd.client.increment('myMetric');
```