From f0ad7e563c69958c8f328105f0011cf8b7203666 Mon Sep 17 00:00:00 2001 From: Konstantin Pogorelov Date: Thu, 21 Apr 2016 11:37:36 +0200 Subject: [PATCH] extend white/black-listing, update readme --- README.md | 6 ++++-- src/index.js | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7ac3206..9a66f43 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Included metrics: * `up`: normally is just 1 * `nodejs_memory_heap_total_bytes` and `nodejs_memory_heap_used_bytes` -* `http_request_total`: count of http requests labeled with status_code +* `http_request_seconds`: http latency histogram labeled with status_code ## Install @@ -29,6 +29,7 @@ const ## Options * **prefix**: prefix added to every metric name + * **whitelist**, **blacklist**: array of strings or regexp. These which metrics to include/exclude ## Example @@ -40,7 +41,8 @@ const express = require("express"), promBundle = require("express-prom-bundle"); app.use(promBundle({ - prefix: "demo_app:something" + prefix: "demo_app:something", + blacklist: ["up"] })); app.get("/hello", (req, res) => res.send("ok")); diff --git a/src/index.js b/src/index.js index 2c75814..b73d6b7 100644 --- a/src/index.js +++ b/src/index.js @@ -5,10 +5,13 @@ const onFinished = require("on-finished"); function filterArrayByRegExps(array, regexps) { - let compiled = regexps.map(regexp => new RegExp(regexp)); return array.filter(element => { - for (let regexp of compiled) { - if (element.match(regexp)) { + for (let regexp of regexps) { + if (regexp instanceof RegExp) { + if (element.match(regexp)) { + return true; + } + } else if (element == regexp) { return true; } }