Skip to content

Agnostic Express middleware to allo sen metric for different collectors

Notifications You must be signed in to change notification settings

devmasx/express-metrics-middleware

Repository files navigation

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',
    //   path: '/users/1',
    //   status: '200',
    //   expressRoute: '/users/:id',
    //   timeInMs: 2.489832,
    //   requestContentLength: 0,
    //   responseContentLength: 16,
    // }
  },
};
app.use(metricsMiddleware(collector));

About

Agnostic Express middleware to allo sen metric for different collectors

Resources

Stars

Watchers

Forks

Packages

No packages published