From 7513c045c16cbe30c02c44be3fbe0756693e238d Mon Sep 17 00:00:00 2001 From: sveisvei Date: Sun, 4 Dec 2016 18:08:19 +0100 Subject: [PATCH] add single toggle metric endpoint --- lib/routes/metrics.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/routes/metrics.js b/lib/routes/metrics.js index a38dda8955..d5075fa1fd 100644 --- a/lib/routes/metrics.js +++ b/lib/routes/metrics.js @@ -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));