http-metrics-middleware
Advanced tools
Comparing version 1.0.1 to 1.1.0
19
index.js
@@ -0,1 +1,2 @@ | ||
const accepts = require('accepts'); | ||
const express = require('express'); | ||
@@ -126,6 +127,18 @@ const promClient = require('prom-client'); | ||
if (req.headers['x-forwarded-for']) { | ||
return res.sendStatus(404); | ||
res.writeHead(404, { | ||
'Content-Type': 'text/plain', | ||
}); | ||
return res.end('Not Found'); | ||
} | ||
res.type('text'); | ||
return res.send(promClient.register.metrics()); | ||
res.statusCode = 200; | ||
const accept = accepts(req); | ||
switch (accept.type(['text', 'json'])) { | ||
case 'json': | ||
res.setHeader('Content-Type', 'application/json'); | ||
return res.end(JSON.stringify(promClient.register.getMetricsAsJSON())); | ||
case 'text': | ||
default: | ||
res.setHeader('Content-Type', 'text/plain'); | ||
return res.end(promClient.register.metrics()); | ||
} | ||
} | ||
@@ -132,0 +145,0 @@ |
{ | ||
"name": "http-metrics-middleware", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Express middleware for adding common prometheus metrics", | ||
@@ -29,2 +29,3 @@ "author": "QlikTech International AB", | ||
"dependencies": { | ||
"accepts": "1.3.5", | ||
"express": "4.16.2", | ||
@@ -34,15 +35,13 @@ "lodash": "4.17.5", | ||
"performance-now": "2.1.0", | ||
"prom-client": "10.2.3", | ||
"prom-client": "11.0.0", | ||
"url-value-parser": "1.0.0" | ||
}, | ||
"devDependencies": { | ||
"after-work.js": "4.1.0", | ||
"chai": "4.1.2", | ||
"after-work.js": "4.2.0", | ||
"codeclimate-test-reporter": "0.5.0", | ||
"eslint": "4.18.2", | ||
"eslint": "4.19.1", | ||
"eslint-config-airbnb-base": "12.1.0", | ||
"eslint-plugin-import": "2.9.0", | ||
"eslint-plugin-mocha": "4.12.1", | ||
"sinon": "4.4.2" | ||
"eslint-plugin-import": "2.10.0", | ||
"eslint-plugin-mocha": "5.0.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
18382
6
233
7
+ Addedaccepts@1.3.5
+ Addedaccepts@1.3.5(transitive)
+ Addednegotiator@0.6.1(transitive)
+ Addedprom-client@11.0.0(transitive)
- Removedaccepts@1.3.8(transitive)
- Removednegotiator@0.6.3(transitive)
- Removedprom-client@10.2.3(transitive)
Updatedprom-client@11.0.0