diff options
-rw-r--r-- | guix-build-coordinator/agent-messaging/http.scm | 18 | ||||
-rw-r--r-- | guix-build-coordinator/datastore/sqlite.scm | 12 |
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>) |