express-telemetry-middleware

0.0.2 • Public • Published

npm version Build Status Coverage Status

Express Telemetry

  • Express Middleware
  • Triggers
    • on high server load (long delays in the eventLoop)
    • on high response times (high response times)
    • on high machine load (high cpu or memory usage)

Inspired from Electrode's auto-ssr for Hapi.

Installation

npm install --save express-telemetry-middleware

Usage

The installTelemetry instructs the app to use the 3 triggers as middlewares.

if any of the triggers hits a threshold, appOnHighLoad will be set to true.

import installTelemetry from 'express-telemetry-middleware'
import express from 'express';

const app = express();
installTelemetry(app, options);

route("/home", function(req, res) {
  console.log(req.appOnHighLoad);
})

Options

Machine load:

  • loadThreshold || 4;
  • memoryThreshold || 80%;

Server Load:

  • delayThresholdMS || 20

Response Time:

  • longResponseThreshold || 5000;

  • longResponseAmount || 6;

  • disableExpiryMins || 2;

  • headerDigits (3)

  • headerName (X-Response-Time)

  • suffix (false)

added req attributes

Machine load:

  • req.highMachineLoad

Server Load:

  • req.eventLoopDelay
  • req.highServerLoad

Response Time:

  • req.highResponseTimeExpiration
  • req.highResponseTime
  • req.numberOfLongResponses

Package Sidebar

Install

npm i express-telemetry-middleware

Weekly Downloads

1

Version

0.0.2

License

MIT

Last publish

Collaborators

  • bamieh