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.6.0 to 7.0.0

21

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

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

],
"types": "types",
"types": "types/index.d.ts",
"scripts": {

@@ -23,4 +23,3 @@ "test": "NODE_ENV=test node_modules/jasme/run.js",

"coverage": "make coverage",
"dtslint": "dtslint types",
"dtslint-next": "dtslint --onlyTestTsNext types"
"test-types": "tsd"
},

@@ -30,2 +29,4 @@ "author": "Konstantin Pogorelov <or@pluseq.com>",

"dependencies": {
"@types/express": "^4.17.21",
"express": "^4.18.2",
"on-finished": "^2.3.0",

@@ -35,7 +36,4 @@ "url-value-parser": "^2.0.0"

"devDependencies": {
"@types/express": "^4.16.1",
"coveralls": "^3.0.2",
"dtslint": "^0.7.1",
"dts": "^0.1.1",
"eslint": "^5.11.0",
"express": "^4.16.4",
"istanbul": "^0.4.5",

@@ -45,9 +43,10 @@ "jasme": "^6.0.0",

"koa-connect": "^2.0.1",
"prom-client": "^13.0.0",
"prom-client": "^15.0.0",
"supertest": "^3.3.0",
"supertest-koa-agent": "^0.3.0",
"tsd": "^0.30.3",
"typescript": "^3.4.5"
},
"peerDependencies": {
"prom-client": ">=12.0.0"
"prom-client": ">=15.0.0"
},

@@ -59,4 +58,4 @@ "repository": {

"engines": {
"node": ">=10"
"node": ">=18"
}
}

@@ -7,4 +7,6 @@ [![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)

Since version 5 it uses **prom-client** as a peer dependency. See: https://github.com/siimon/prom-client
This library uses **prom-client v15+** as a peer dependency. See: https://github.com/siimon/prom-client
If you need a support for older versions of prom-client (v12-v14), downgrade to express-prom-bundle v6.6.0
Included metrics:

@@ -71,2 +73,3 @@

* **maxAgeSeconds**: the maxAgeSeconds will tell how old a bucket can be before it is reset
* **pruneAgedBuckets**: When enabled, timed out buckets will be removed entirely. By default, buckets are reset to 0.

@@ -164,2 +167,13 @@ ### Transformation callbacks ###

#### Example 3 (return express route definition):
```javascript
app.use(promBundle(/* options? */));
promBundle.normalizePath = (req, opts) => {
// Return the path of the express route (i.e. /v1/user/:id or /v1/timer/automated/:userid/:timerid")
return req.route?.path ?? "NULL";
};
```
## express example

@@ -166,0 +180,0 @@

@@ -115,3 +115,4 @@ const onFinished = require('on-finished');

ageBuckets: opts.ageBuckets,
registers: [opts.promRegistry]
registers: [opts.promRegistry],
pruneAgedBuckets: opts.pruneAgedBuckets
});

@@ -136,4 +137,8 @@ } else if (opts.metricType === 'histogram' || !opts.metricType) {

if (opts.includeUp !== false) {
let prefix = '';
if (opts.promClient && opts.promClient.collectDefaultMetrics) {
prefix = opts.promClient.collectDefaultMetrics.prefix || '';
}
metrics.up = new promClient.Gauge({
name: 'up',
name: `${prefix}up`,
help: '1 = up, 0 = not up',

@@ -140,0 +145,0 @@ registers: [opts.promRegistry]

'use strict';
const CLIENT_CLOSED_REQUEST_CODE = 499;
module.exports = function(res) {
return res.status_code || res.statusCode;
if (res.headersSent) {
return res.status_code || res.statusCode;
} else {
return CLIENT_CLOSED_REQUEST_CODE;
}
};
// TypeScript Version: 2.8
import { Request, RequestHandler, Response, Express } from 'express';
import { DefaultMetricsCollectorConfiguration, Registry } from 'prom-client';
import { DefaultMetricsCollectorConfiguration, Registry, RegistryContentType } from 'prom-client';

@@ -20,3 +20,3 @@ export {};

interface Opts {
interface BaseOptions {
autoregister?: boolean;

@@ -40,15 +40,5 @@

metricType?: 'summary' | 'histogram';
// https://github.com/siimon/prom-client#histogram
buckets?: number[];
// https://github.com/siimon/prom-client#summary
percentiles?: number[];
maxAgeSeconds?: number;
ageBuckets?: number;
metricsPath?: string;
httpDurationMetricName?: string;
promClient?: { collectDefaultMetrics?: DefaultMetricsCollectorConfiguration };
promClient?: { collectDefaultMetrics?: DefaultMetricsCollectorConfiguration<RegistryContentType> };
promRegistry?: Registry;

@@ -70,2 +60,19 @@ normalizePath?: NormalizePathEntry[] | NormalizePathFn;

/** @see https://github.com/siimon/prom-client#summary */
type SummaryOptions = BaseOptions & {
metricType?: 'summary';
percentiles?: number[];
maxAgeSeconds?: number;
ageBuckets?: number;
pruneAgedBuckets?: boolean;
}
/** @see https://github.com/siimon/prom-client#histogram */
type HistogramOptions = BaseOptions & {
metricType?: 'histogram';
buckets?: number[];
}
type Opts = SummaryOptions | HistogramOptions;
interface Middleware extends RequestHandler {

@@ -72,0 +79,0 @@ metricsMiddleware: RequestHandler;

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