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

express-prom-bundle

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-prom-bundle - npm Package Compare versions

Comparing version 6.5.0 to 6.6.0

2

package.json
{
"name": "express-prom-bundle",
"version": "6.5.0",
"version": "6.6.0",
"description": "express middleware with popular prometheus metrics in one bundle",

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

@@ -55,3 +55,2 @@ [![build status](https://travis-ci.org/jochen-schweizer/express-prom-bundle.png)](https://travis-ci.org/jochen-schweizer/express-prom-bundle) [![Coverage Status](https://coveralls.io/repos/github/jochen-schweizer/express-prom-bundle/badge.svg?branch=master)](https://coveralls.io/github/jochen-schweizer/express-prom-bundle?branch=master) [![license](https://img.shields.io/github/license/mashape/apistatus.svg?maxAge=2592000)](https://www.tldrlegal.com/l/mit) [![NPM version](https://badge.fury.io/js/express-prom-bundle.png)](http://badge.fury.io/js/express-prom-bundle)

* **metricType**: histogram/summary selection. See more details below
* **bypass**: function taking express request as an argument and determines whether the given request should be excluded in the metrics, default: **() => false**
* **httpDurationMetricName**: Allows you change the name of HTTP duration metric, default: **`http_request_duration_seconds`**.

@@ -94,3 +93,16 @@

* **metricsApp**: Allows you to attach the metrics endpoint to a different express app. You probably want to use it in combination with `autoregister: false`.
* **bypass**: An object that takes onRequest and onFinish callbacks that determines whether the given request should be excluded in the metrics. Default:
```js
{
onRequest: (req) => false,
onFinish: (req, res) => false
}
```
`onRequest` is run directly in the middleware chain, before the request is processed. `onFinish` is run after the request has been processed, and has access to the express response object in addition to the request object. Both callbacks are optional, and if one or both returns true the request is excluded.
As a shorthand, just the onRequest callback can be used instead of the object.
### More details on includePath option

@@ -97,0 +109,0 @@

@@ -164,2 +164,10 @@ const onFinished = require('on-finished');

if (typeof opts.bypass === 'function') {
opts.bypass = {
onRequest: opts.bypass
};
} else if (!opts.bypass) {
opts.bypass = {};
}
const middleware = function (req, res, next) {

@@ -174,3 +182,3 @@ const path = req.originalUrl || req.url; // originalUrl gets lost in koa-connect?

// if you wish to disable /metrics use autoregister:false instead
if (opts.bypass && opts.bypass(req)) {
if (opts.bypass.onRequest && opts.bypass.onRequest(req)) {
return next();

@@ -187,2 +195,6 @@ }

onFinished(res, () => {
if (opts.bypass.onFinish && opts.bypass.onFinish(req, res)) {
return;
}
if (opts.includeStatusCode) {

@@ -189,0 +201,0 @@ labels.status_code = opts.formatStatusCode(res, opts);

@@ -30,3 +30,8 @@ // TypeScript Version: 2.8

bypass?: (req: Request) => boolean;
bypass?:
| ((req: Request) => boolean)
| {
onRequest?: (req: Request) => boolean;
onFinish?: (req: Request, res: Response) => boolean;
};

@@ -33,0 +38,0 @@ excludeRoutes?: Array<string | RegExp>;

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