aboutsummaryrefslogtreecommitdiff
path: root/guix-build-coordinator
diff options
context:
space:
mode:
Diffstat (limited to 'guix-build-coordinator')
-rw-r--r--guix-build-coordinator/datastore/sqlite.scm53
1 files changed, 53 insertions, 0 deletions
diff --git a/guix-build-coordinator/datastore/sqlite.scm b/guix-build-coordinator/datastore/sqlite.scm
index c3b62b2..215c07e 100644
--- a/guix-build-coordinator/datastore/sqlite.scm
+++ b/guix-build-coordinator/datastore/sqlite.scm
@@ -351,6 +351,59 @@ PRAGMA optimize;")
(spawn-fiber
(lambda ()
+ (let* ((registry
+ (slot-ref datastore 'metrics-registry))
+ (dbstat-metrics
+ (map
+ (lambda (name)
+ (let ((metric-name
+ (string-append "datastore_dbstat_"
+ (symbol->string name))))
+ (cons
+ name
+ (or (metrics-registry-fetch-metric registry
+ metric-name)
+ (make-gauge-metric registry metric-name
+ #:labels '(name))))))
+ '(pageno ncell payload unused mx_payload pgsize))))
+
+ (while #t
+ (with-exception-handler
+ (lambda (exn)
+ (simple-format
+ (current-error-port)
+ "exception fetching dbstat metrics: ~A\n" exn))
+ (lambda ()
+ (call-with-worker-thread
+ (slot-ref datastore 'worker-reader-thread-channel)
+ (lambda (db)
+ (let ((statement
+ (sqlite-prepare
+ db
+ "
+SELECT * FROM dbstat WHERE aggregate = true"
+ #:cache? #t))
+ (dbstat-columns
+ '(#f #f pageno #f ncell payload unused mx_payload #f pgsize)))
+ (sqlite-fold
+ (lambda (row _)
+ (for-each
+ (lambda (column val)
+ (when column
+ (metric-set (assq-ref dbstat-metrics column)
+ val
+ #:label-values
+ `((name . ,(vector-ref row 0))))))
+ dbstat-columns
+ (vector->list row)))
+ #f
+ statement)
+ (sqlite-reset statement))))
+ (sleep (* 60 60 60)))
+ #:unwind? #t)))))
+
+ (spawn-fiber
+ (lambda ()
(while #t
(sleep (* 60 10)) ; 10 minutes
(with-exception-handler