1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00

add single toggle metric endpoint

This commit is contained in:
sveisvei 2016-12-04 18:08:19 +01:00
parent 5bf0b36588
commit 7513c045c1

View File

@ -24,6 +24,17 @@ module.exports = function (app, config) {
res.json(metrics.getTogglesMetrics());
});
app.get('/client/metrics/feature-toggles/:name', (req, res) => {
const name = req.params.name;
const data = metrics.getTogglesMetrics();
const lastHour = data.lastHour[name] || {};
const lastMinute = data.lastMinute[name] || {};
res.json({
lastHour,
lastMinute,
});
});
app.post('/client/metrics', (req, res) => {
const data = req.body;
const clientIp = req.ip;
@ -62,7 +73,7 @@ module.exports = function (app, config) {
instanceId: cleaned.instanceId,
clientIp,
}))
.then(() => logger.info(`New client registered with
.then(() => logger.info(`New client registered with
appName=${cleaned.appName} and instanceId=${cleaned.instanceId}`))
.catch(err => logger.error('failed to register client', err));