aboutsummaryrefslogtreecommitdiff
path: root/guix-data-service/utils.scm
diff options
context:
space:
mode:
Diffstat (limited to 'guix-data-service/utils.scm')
-rw-r--r--guix-data-service/utils.scm21
1 files changed, 21 insertions, 0 deletions
diff --git a/guix-data-service/utils.scm b/guix-data-service/utils.scm
index 351b656..d72fa55 100644
--- a/guix-data-service/utils.scm
+++ b/guix-data-service/utils.scm
@@ -57,6 +57,7 @@
get-gc-metrics-updater
get-port-metrics-updater
+ get-guix-metrics-updater
call-with-sigint
run-server/patched
@@ -628,6 +629,26 @@ available. Return the resource once PROC has returned."
(not (member file '("." "..")))))
'()))))))
+(define (get-guix-metrics-updater registry)
+ (define guix-db "/var/guix/db/db.sqlite")
+ (define guix-db-wal (string-append guix-db "-wal"))
+
+ (let ((guix-db-bytes-metric
+ (make-gauge-metric registry "guix_db_bytes"))
+ (guix-db-wal-bytes-metric
+ (make-gauge-metric registry "guix_db_wal_bytes")))
+ (lambda ()
+ (with-exception-handler
+ (lambda _
+ #f)
+ (lambda ()
+ (metric-set guix-db-bytes-metric (stat:size (stat guix-db)))
+ (metric-set guix-db-wal-bytes-metric
+ (if (file-exists? guix-db-wal)
+ (stat:size (stat guix-db-wal))
+ 0)))
+ #:unwind? #t))))
+
;; This variant of run-server from the fibers library supports running
;; multiple servers within one process.
(define run-server/patched