mirror of https://github.com/calzoneman/sync.git
deps: upgrade prom-client
This commit is contained in:
parent
5f3d0859fd
commit
08c0cfcd58
|
@ -28,7 +28,7 @@
|
|||
"morgan": "^1.10.0",
|
||||
"mysql": "^2.18.1",
|
||||
"nodemailer": "^6.5.0",
|
||||
"prom-client": "^10.0.2",
|
||||
"prom-client": "^13.1.0",
|
||||
"proxy-addr": "^2.0.6",
|
||||
"pug": "^3.0.2",
|
||||
"redis": "^3.0.2",
|
||||
|
|
|
@ -5,7 +5,6 @@ import { parse as parseURL } from 'url';
|
|||
const LOGGER = require('@calzoneman/jsli')('prometheus-server');
|
||||
|
||||
let server = null;
|
||||
let defaultMetricsTimer = null;
|
||||
|
||||
export function init(prometheusConfig) {
|
||||
if (server !== null) {
|
||||
|
@ -14,7 +13,7 @@ export function init(prometheusConfig) {
|
|||
return;
|
||||
}
|
||||
|
||||
defaultMetricsTimer = collectDefaultMetrics();
|
||||
collectDefaultMetrics();
|
||||
|
||||
server = http.createServer((req, res) => {
|
||||
if (req.method !== 'GET'
|
||||
|
@ -24,10 +23,18 @@ export function init(prometheusConfig) {
|
|||
return;
|
||||
}
|
||||
|
||||
res.writeHead(200, {
|
||||
'Content-Type': register.contentType
|
||||
register.metrics().then(metrics => {
|
||||
res.writeHead(200, {
|
||||
'Content-Type': register.contentType
|
||||
});
|
||||
res.end(metrics);
|
||||
}).catch(error => {
|
||||
LOGGER.error('Error generating prometheus metrics: %s', error.stack);
|
||||
res.writeHead(500, {
|
||||
'Content-Type': 'text/plain'
|
||||
});
|
||||
res.end('Internal Server Error');
|
||||
});
|
||||
res.end(register.metrics());
|
||||
});
|
||||
|
||||
server.on('error', error => {
|
||||
|
@ -47,6 +54,4 @@ export function init(prometheusConfig) {
|
|||
export function shutdown() {
|
||||
server.close();
|
||||
server = null;
|
||||
clearInterval(defaultMetricsTimer);
|
||||
defaultMetricsTimer = null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue