aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2020-05-23 09:12:46 +0100
committerChristopher Baines <mail@cbaines.net>2020-05-23 09:12:46 +0100
commit82809c55e59d2c4e7c25398c3e7ae58d7042a3cd (patch)
tree0d53da6a5465cf3c18174defe324e2d83d7cae4a
parent06c30f561d2080ff7f18715e9956866004636716 (diff)
downloadbuild-coordinator-82809c55e59d2c4e7c25398c3e7ae58d7042a3cd.tar
build-coordinator-82809c55e59d2c4e7c25398c3e7ae58d7042a3cd.tar.gz
Track unprocessed hook events by event
-rw-r--r--guix-build-coordinator/agent-messaging/http.scm18
-rw-r--r--guix-build-coordinator/datastore/sqlite.scm12
2 files changed, 23 insertions, 7 deletions
diff --git a/guix-build-coordinator/agent-messaging/http.scm b/guix-build-coordinator/agent-messaging/http.scm
index 54a04ee..b74e114 100644
--- a/guix-build-coordinator/agent-messaging/http.scm
+++ b/guix-build-coordinator/agent-messaging/http.scm
@@ -178,7 +178,8 @@ port. Also, the port used can be changed by passing the --port option.\n"
(unprocessed-hook-events-total
(make-gauge-metric registry
(string-append namespace
- "_unprocessed_hook_events_total"))))
+ "_unprocessed_hook_events_total")
+ #:labels '(event))))
(define (zero-metric-for-agents metric)
(for-each (lambda (agent-details)
(metric-set metric
@@ -224,8 +225,19 @@ port. Also, the port used can be changed by passing the --port option.\n"
`((agent_id . ,agent-id)))))
(datastore-count-build-allocation-plan-entries datastore))
- (metric-set unprocessed-hook-events-total
- (datastore-count-unprocessed-hook-events datastore)))))
+ (for-each (match-lambda
+ ((event . _)
+ (metric-set unprocessed-hook-events-total
+ 0
+ #:label-values
+ `((event . ,event)))))
+ (build-coordinator-hooks build-coordinator))
+ (for-each (lambda (event-count)
+ (metric-set unprocessed-hook-events-total
+ (assq-ref event-count 'count)
+ #:label-values
+ `((event . ,(assq-ref event-count 'event)))))
+ (datastore-count-unprocessed-hook-events datastore)))))
(define (controller request
method-and-path-components
diff --git a/guix-build-coordinator/datastore/sqlite.scm b/guix-build-coordinator/datastore/sqlite.scm
index 5c1fddc..10c0897 100644
--- a/guix-build-coordinator/datastore/sqlite.scm
+++ b/guix-build-coordinator/datastore/sqlite.scm
@@ -1073,13 +1073,17 @@ VALUES (:event, :arguments)")))
(sqlite-prepare
db
"
-SELECT COUNT(*) FROM unprocessed_hook_events")))
+SELECT event, COUNT(*) FROM unprocessed_hook_events GROUP BY event")))
- (let ((count (match (sqlite-step statement)
- (#(count) count))))
+ (let ((counts (sqlite-map
+ (match-lambda
+ (#(event count)
+ `((event . ,event)
+ (count . ,count))))
+ statement)))
(sqlite-reset statement)
- count)))))
+ counts)))))
(define-method (datastore-list-unprocessed-hook-events
(datastore <sqlite-datastore>)