Skip to content
Snippets Groups Projects
Commit 36758da2 authored by feed back's avatar feed back
Browse files

[263] Add message lag gauge.

parent b329d6ae
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,10 @@ const _counters = { ...@@ -10,6 +10,10 @@ const _counters = {
ERRORS: 'ERRORS', ERRORS: 'ERRORS',
} }
const _gauges = {
MESSAGE_LAG: 'MESSAGE_LAG',
}
const messageDirection = { const messageDirection = {
INBOUND: 'inbound', INBOUND: 'inbound',
OUTBOUND: 'outbound', OUTBOUND: 'outbound',
...@@ -24,6 +28,7 @@ const run = () => { ...@@ -24,6 +28,7 @@ const run = () => {
const registry = new prometheus.Registry() const registry = new prometheus.Registry()
prometheus.collectDefaultMetrics({ registry }) prometheus.collectDefaultMetrics({ registry })
const c = _counters const c = _counters
const g = _gauges
const counters = { const counters = {
[c.ERRORS]: new prometheus.Counter({ [c.ERRORS]: new prometheus.Counter({
...@@ -54,17 +59,30 @@ const run = () => { ...@@ -54,17 +59,30 @@ const run = () => {
}), }),
} }
return { registry, counters } const gauges = {
[g.MESSAGE_LAG]: new prometheus.Gauge({
name: 'message_lag',
help: 'Times the message lag from signald',
registers: [registry],
labelNames: ['channelPhoneNumber'],
}),
}
return { registry, counters, gauges }
} }
// (string, [string]) -> void // (string, [string]) -> void
const incrementCounter = (counter, labels) => app.metrics.counters[counter].labels(...labels).inc() const incrementCounter = (counter, labels) => app.metrics.counters[counter].labels(...labels).inc()
const setGauge = (gauge, labels, value) => app.metrics.gauges[gauge].labels(...labels).set(value)
module.exports = { module.exports = {
run, run,
register, register,
incrementCounter, incrementCounter,
setGauge,
counters: _counters, counters: _counters,
gauges: _gauges,
messageDirection, messageDirection,
errorTypes, errorTypes,
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment