Socket
Socket
Sign inDemoInstall

express-prom-bundle

Package Overview
Dependencies
Maintainers
1
Versions
53
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 3.1.0 to 3.2.0

4

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

@@ -20,3 +20,3 @@ "main": "src/index.js",

"on-finished": "^2.3.0",
"prom-client": "^10.0.2",
"prom-client": "^10.1.0",
"url-value-parser": "^1.0.0"

@@ -23,0 +23,0 @@ },

@@ -20,3 +20,3 @@ [![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)

## Sample uUsage
## Sample Usage

@@ -51,2 +51,4 @@ ```javascript

* **includePath**: URL path (see importent details below), default: **false**
* **customLabels**: an object containing extra labels, e.g. ```{project_name: 'hello_world'}```.
Most useful together with **transformLabels** callback, otherwise it's better to use native Prometheus relabeling.

@@ -57,2 +59,3 @@ Extra transformation callbacks:

* **formatStatusCode**: `function(res)` producing final status code from express `res` object, e.g. you can combine `200`, `201` and `204` to just `2xx`.
* **transformLabels**: `function(labels, req, res)` transforms the **labels** object, e.g. setting dynamic values to **customLabels**

@@ -68,2 +71,3 @@ Other options:

* **excludeRoutes**: array of strings or regexp specifying which routes should be skipped for `http_request_duration_seconds` metric. It uses `req.originalUrl` as subject when checking. You want to use express or meddleware features instead of this option.
* **httpDurationMetricName**: name of the request duration histogram metric. (Default: `http_request_duration_seconds`)

@@ -174,2 +178,5 @@ ### More details on includePath option

* **3.2.0**
* added options **customLabels**, **transformLabels**
* upgrade **prom-client** to 10.1.0
* **3.1.0**

@@ -176,0 +183,0 @@ * upgrade **prom-client** to 10.0.0

@@ -69,3 +69,3 @@ 'use strict';

const httpMtricName = opts.httpDurationMetricName || 'http_request_duration_seconds';
const httpMetricName = opts.httpDurationMetricName || 'http_request_duration_seconds';

@@ -77,3 +77,3 @@ const metricTemplates = {

}),
'http_request_duration_seconds': () => {
[httpMetricName]: () => {
const labels = ['status_code'];

@@ -86,4 +86,7 @@ if (opts.includeMethod) {

}
if (opts.customLabels){
labels.push.apply(labels, Object.keys(opts.customLabels));
}
const metric = new promClient.Histogram({
name: httpMtricName,
name: httpMetricName,
help: 'duration histogram of http responses labeled with: ' + labels.join(', '),

@@ -125,5 +128,5 @@ labelNames: labels,

if (metrics[httpMtricName]) {
if (metrics[httpMetricName]) {
labels = {};
let timer = metrics[httpMtricName].startTimer(labels);
let timer = metrics[httpMetricName].startTimer(labels);
onFinished(res, () => {

@@ -139,2 +142,8 @@ if (opts.includeStatusCode) {

}
if (opts.customLabels) {
Object.assign(labels, opts.customLabels);
}
if (opts.transformLabels) {
opts.transformLabels(labels, req, res);
}
timer();

@@ -141,0 +150,0 @@ });

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