2016-11-30 23:41:57 +01:00
|
|
|
'use strict';
|
|
|
|
|
2017-06-28 14:21:05 +02:00
|
|
|
const { register: prometheusRegister } = require('prom-client');
|
2018-12-03 08:59:13 +01:00
|
|
|
const Controller = require('./controller');
|
2016-11-30 23:41:57 +01:00
|
|
|
|
2018-12-03 08:59:13 +01:00
|
|
|
class BackstageController extends Controller {
|
2018-11-24 12:48:19 +01:00
|
|
|
constructor(config) {
|
2018-12-03 08:59:13 +01:00
|
|
|
super();
|
2017-06-28 10:20:22 +02:00
|
|
|
|
2018-11-24 12:48:19 +01:00
|
|
|
if (config.serverMetrics) {
|
2018-12-03 08:59:13 +01:00
|
|
|
this.get('/prometheus', (req, res) => {
|
2018-11-24 12:48:19 +01:00
|
|
|
res.set('Content-Type', prometheusRegister.contentType);
|
|
|
|
res.end(prometheusRegister.metrics());
|
|
|
|
});
|
|
|
|
}
|
2016-11-30 23:41:57 +01:00
|
|
|
}
|
2018-11-24 12:48:19 +01:00
|
|
|
}
|
2017-06-28 10:20:22 +02:00
|
|
|
|
2018-11-24 12:48:19 +01:00
|
|
|
module.exports = BackstageController;
|