express-metrics-middleware-exporter
v0.3.1
Published
## Usage ``` npm install express-metrics-middleware-exporter ```
Downloads
4
Readme
express-metrics-middleware-exporter
Usage
npm install express-metrics-middleware-exporter
import { ICollector, metricsMiddleware } from 'express-metrics-middleware-exporter';
import express, { Request, Response } from 'express';
const app = express();
const collector: ICollector = {
// Process metrics data with any type of collector
onRequestFinish(metricsData: IMetricsData, request: Request, response: Response) {
console.log(metricsData);
// {
// method: 'GET',
// route: '/users/:id',
// status: '200',
// requestContentLength: 0,
// responseContentLength: 16,
// timeInMs: 2.489832,
// }
},
};
app.use(metricsMiddleware(collector));