aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2020-05-21 22:22:51 +0100
committerChristopher Baines <mail@cbaines.net>2020-05-21 22:22:51 +0100
commit46a95a9e80be141165304fed4547d816fb748996 (patch)
tree072666c1961fe36334db1e41b351c3e808c25db0
parentf3475b5b015e14aaf63e42bc4332d7c8067c96bc (diff)
downloadbuild-coordinator-46a95a9e80be141165304fed4547d816fb748996.tar
build-coordinator-46a95a9e80be141165304fed4547d816fb748996.tar.gz
Report the number of unprocessed hook events
-rw-r--r--guix-build-coordinator/agent-messaging/http.scm11
-rw-r--r--guix-build-coordinator/datastore.scm1
-rw-r--r--guix-build-coordinator/datastore/sqlite.scm18
3 files changed, 28 insertions, 2 deletions
diff --git a/guix-build-coordinator/agent-messaging/http.scm b/guix-build-coordinator/agent-messaging/http.scm
index 5ad0a4b..54a04ee 100644
--- a/guix-build-coordinator/agent-messaging/http.scm
+++ b/guix-build-coordinator/agent-messaging/http.scm
@@ -174,7 +174,11 @@ port. Also, the port used can be changed by passing the --port option.\n"
(make-gauge-metric registry
(string-append namespace
"_build_allocation_plan_total")
- #:labels '(agent_id))))
+ #:labels '(agent_id)))
+ (unprocessed-hook-events-total
+ (make-gauge-metric registry
+ (string-append namespace
+ "_unprocessed_hook_events_total"))))
(define (zero-metric-for-agents metric)
(for-each (lambda (agent-details)
(metric-set metric
@@ -218,7 +222,10 @@ port. Also, the port used can be changed by passing the --port option.\n"
count
#:label-values
`((agent_id . ,agent-id)))))
- (datastore-count-build-allocation-plan-entries datastore)))))
+ (datastore-count-build-allocation-plan-entries datastore))
+
+ (metric-set unprocessed-hook-events-total
+ (datastore-count-unprocessed-hook-events datastore)))))
(define (controller request
method-and-path-components
diff --git a/guix-build-coordinator/datastore.scm b/guix-build-coordinator/datastore.scm
index 8b689a5..7f49583 100644
--- a/guix-build-coordinator/datastore.scm
+++ b/guix-build-coordinator/datastore.scm
@@ -35,6 +35,7 @@
(re-export datastore-list-unprocessed-builds)
(re-export datastore-list-unprocessed-builds-with-built-inputs)
(re-export datastore-fetch-unprocessed-builds-with-propagated-priorities)
+(re-export datastore-count-unprocessed-hook-events)
(re-export datastore-list-unprocessed-hook-events)
(re-export datastore-delete-unprocessed-hook-event)
(re-export datastore-list-agent-builds)
diff --git a/guix-build-coordinator/datastore/sqlite.scm b/guix-build-coordinator/datastore/sqlite.scm
index b566180..4f43c5b 100644
--- a/guix-build-coordinator/datastore/sqlite.scm
+++ b/guix-build-coordinator/datastore/sqlite.scm
@@ -42,6 +42,7 @@
datastore-list-unprocessed-builds
datastore-list-unprocessed-builds-with-built-inputs
datastore-fetch-unprocessed-builds-with-propagated-priorities
+ datastore-count-unprocessed-hook-events
datastore-list-unprocessed-hook-events
datastore-delete-unprocessed-hook-event
datastore-list-agent-builds
@@ -1008,6 +1009,23 @@ VALUES (:event, :arguments)")))
(sqlite-reset statement))
#t)
+(define-method (datastore-count-unprocessed-hook-events
+ (datastore <sqlite-datastore>))
+ (call-with-worker-thread
+ (slot-ref datastore 'worker-reader-thread-channel)
+ (lambda (db)
+ (let ((statement
+ (sqlite-prepare
+ db
+ "
+SELECT COUNT(*) FROM unprocessed_hook_events")))
+
+ (let ((count (match (sqlite-step statement)
+ (#(count) count))))
+ (sqlite-reset statement)
+
+ count)))))
+
(define-method (datastore-list-unprocessed-hook-events
(datastore <sqlite-datastore>)
limit)