Skip to content

Commit f353344

Browse files
committed
expose latest NATS message sequence number as metric
1 parent fc9601d commit f353344

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/match.js

+8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {ok} from 'node:assert'
22
import {cpus as osCpus} from 'node:os'
33
import {
4+
Gauge,
45
Counter,
56
Summary,
67
} from 'prom-client'
@@ -85,6 +86,11 @@ const runGtfsMatching = async (cfg, opt = {}) => {
8586
...opt,
8687
}
8788

89+
const natsMsgSeq = new Gauge({
90+
name: 'nats_msg_seq',
91+
help: 'sequence number of the latest NATS message being processed',
92+
registers: [register],
93+
})
8894
const successesTotal = new Counter({
8995
name: 'matching_successes_total',
9096
help: 'number of successfully matched movements/trips',
@@ -176,6 +182,8 @@ const runGtfsMatching = async (cfg, opt = {}) => {
176182
seq,
177183
dataSlice: data.slice(0, 100).toString('utf8'),
178184
}, 'processing AUS IstFahrt msg')
185+
natsMsgSeq.set(seq) // todo: is `seq` an integer?
186+
179187
try {
180188
const ausIstFahrt = msg.json(data)
181189
// todo: validate against schema, error-log and abort if invalid

0 commit comments

Comments
 (0)