1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-01 00:08:27 +01:00
unleash.unleash/lib/metrics.js
ivaosthu b46fb7507f Server Metrics with Prometheus
Implementation use internal eventBus to enable loose counting in the app.

read more at https://prometheus.io/

Closes #98
2016-11-30 23:41:57 +01:00

24 lines
747 B
JavaScript

const events = require('./events');
exports.startMonitoring = (enable, eventBus) => {
if (!enable) {
return;
}
const client = require('prom-client');
const toggleFetch = new client.Counter('toggles_fetch_counter', 'Number of fetch toggles request');
const clientRegister = new client.Counter('client_register_counter', 'Number client register requests');
const clientMetrics = new client.Counter('client_metrics_counter', 'Number client metrics requests');
eventBus.on(events.TOGGLES_FETCH, () => {
toggleFetch.inc();
});
eventBus.on(events.CLIENT_REGISTER, () => {
clientRegister.inc();
});
eventBus.on(events.CLIENT_METRICS, () => {
clientMetrics.inc();
});
};