Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-prometheus-middleware

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-prometheus-middleware - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

10

CHANGELOG.md

@@ -5,2 +5,12 @@ # Change Log

<a name="0.2.0"></a>
# [0.2.0](https://github.com/joao-fontenele/express-prometheus-middleware/compare/v0.1.0...v0.2.0) (2018-08-14)
### Features
* export a middleware factory ([af1acd6](https://github.com/joao-fontenele/express-prometheus-middleware/commit/af1acd6))
<a name="0.1.0"></a>

@@ -7,0 +17,0 @@ # 0.1.0 (2018-08-11)

2

package.json
{
"name": "express-prometheus-middleware",
"version": "0.1.0",
"version": "0.2.0",
"description": "red/use metrics for express applications",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -15,34 +15,34 @@ const express = require('express');

const app = express();
module.exports = () => {
const app = express();
/**
* Corresponds to the R(equest rate), E(error rate), and D(uration of requests),
* of the RED metrics.
*/
const redMiddleware = ResponseTime((req, res, time) => {
const { path, method } = req;
/**
* Corresponds to the R(equest rate), E(error rate), and D(uration of requests),
* of the RED metrics.
*/
const redMiddleware = ResponseTime((req, res, time) => {
const { path, method } = req;
if (path !== '/metrics') {
// will replace ids from the route with `#val` placeholder this serves to
// measure the same routes, e.g., /image/id1, and /image/id2, will be
// treated as the same route
const route = normalizePath(path);
const status = normalizeStatusCode(res.statusCode);
if (path !== '/metrics') {
// will replace ids from the route with `#val` placeholder this serves to
// measure the same routes, e.g., /image/id1, and /image/id2, will be
// treated as the same route
const route = normalizePath(path);
const status = normalizeStatusCode(res.statusCode);
requestCount.inc({ route, method, status });
requestCount.inc({ route, method, status });
requestDuration.labels(method, route, status).observe(time);
}
});
requestDuration.labels(method, route, status).observe(time);
}
});
// when this file is required, we will start to collect automatically
Prometheus.collectDefaultMetrics();
// when this file is required, we will start to collect automatically
Prometheus.collectDefaultMetrics();
app.use(redMiddleware);
app.use(redMiddleware);
app.get('/metrics', (req, res) => {
res.set('Content-Type', Prometheus.register.contentType);
res.end(Prometheus.register.metrics());
});
module.exports = app;
app.get('/metrics', (req, res) => {
res.set('Content-Type', Prometheus.register.contentType);
res.end(Prometheus.register.metrics());
});
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc