[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
05/06: Report the size of the guix database and WAL file
From: |
Christopher Baines |
Subject: |
05/06: Report the size of the guix database and WAL file |
Date: |
Thu, 7 Mar 2024 05:08:38 -0500 (EST) |
cbaines pushed a commit to branch master
in repository data-service.
commit 184d3416717971cdf0c8b84709a7180efd5127b9
Author: Christopher Baines <mail@cbaines.net>
AuthorDate: Tue Mar 5 11:15:04 2024 +0000
Report the size of the guix database and WAL file
Since the Guix daemon doesn't export these metrics, instrument it here.
---
guix-data-service/utils.scm | 21 +++++++++++++++++++++
guix-data-service/web/controller.scm | 6 +++++-
2 files changed, 26 insertions(+), 1 deletion(-)
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
diff --git a/guix-data-service/web/controller.scm
b/guix-data-service/web/controller.scm
index 1ac081b..1fb369c 100644
--- a/guix-data-service/web/controller.scm
+++ b/guix-data-service/web/controller.scm
@@ -201,7 +201,10 @@
(get-gc-metrics-updater registry))
(port-metrics-updater
- (get-port-metrics-updater registry)))
+ (get-port-metrics-updater registry))
+
+ (guix-metrics-updater
+ (get-guix-metrics-updater registry)))
(define guile-time-metrics-updater
(let ((internal-real-time
@@ -437,6 +440,7 @@
(gc-metrics-updater)
(port-metrics-updater)
+ (guix-metrics-updater)
(guile-time-metrics-updater)
(list (build-response
- branch master updated (26f517d -> 5f80856), Christopher Baines, 2024/03/07
- 02/06: Copy the port monitoring fiber from the build coordinator, Christopher Baines, 2024/03/07
- 04/06: Add exception handling to the process-jobs script, Christopher Baines, 2024/03/07
- 01/06: Instrument resource pool checkout failures, Christopher Baines, 2024/03/07
- 05/06: Report the size of the guix database and WAL file,
Christopher Baines <=
- 03/06: Further fix handling exceptions when computing channel instances, Christopher Baines, 2024/03/07
- 06/06: Allow prioritising jobs from specific repositories, Christopher Baines, 2024/03/07