From 650fd773f7ffc9e8819e9b3ee47b414cc817bcb3 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Mon, 24 Apr 2023 11:10:18 +0100 Subject: Add a gauge for the events channel state id --- bffe/server.scm | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/bffe/server.scm b/bffe/server.scm index 2cc6322..8157843 100644 --- a/bffe/server.scm +++ b/bffe/server.scm @@ -121,7 +121,8 @@ (raise-exception exn)) (result result)))) -(define (make-events-channel event-source initial-state-id) +(define* (make-events-channel event-source initial-state-id + #:key metrics-registry) (let* ((submission-channel (make-channel)) (listener-channels-box (make-atomic-box vlist-null)) @@ -129,7 +130,11 @@ (event-buffer (make-vector buffer-size)) (current-state-id-and-event-buffer-index-box - (make-atomic-box (cons 0 -1)))) + (make-atomic-box (cons 0 -1))) + + (events-channel-state-id-gauge + (make-gauge-metric metrics-registry + "events_channel_state_id"))) (define (get-state-id) (match (atomic-box-ref @@ -214,7 +219,10 @@ (vector-set! event-buffer new-event-index - (list id event-name data)))))) + (list id event-name data)) + + (metric-set events-channel-state-id-gauge + id))))) (spawn-fiber (lambda () @@ -492,7 +500,8 @@ get-state-id (make-events-channel event-source - initial-state-id)) + initial-state-id + #:metrics-registry metrics-registry)) (controller (apply make-controller assets-directory metrics-registry -- cgit v1.2.3