diff options
author | Christopher Baines <mail@cbaines.net> | 2024-04-17 09:35:58 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2024-04-17 09:35:58 +0100 |
commit | d75181ebeba1caa8663e09b9dbe504912b199edf (patch) | |
tree | 9f57965df90ace65bef7ed17a4551bf9feaf8f95 /guix-build-coordinator | |
parent | 4ac4141741214fe6e97fb2ebe405d36228aea596 (diff) | |
download | build-coordinator-d75181ebeba1caa8663e09b9dbe504912b199edf.tar build-coordinator-d75181ebeba1caa8663e09b9dbe504912b199edf.tar.gz |
Use the new process metrics exporter
Diffstat (limited to 'guix-build-coordinator')
-rw-r--r-- | guix-build-coordinator/agent-messaging/http/server.scm | 21 | ||||
-rw-r--r-- | guix-build-coordinator/utils.scm | 51 |
2 files changed, 13 insertions, 59 deletions
diff --git a/guix-build-coordinator/agent-messaging/http/server.scm b/guix-build-coordinator/agent-messaging/http/server.scm index 7bfc0b5..85ba0d4 100644 --- a/guix-build-coordinator/agent-messaging/http/server.scm +++ b/guix-build-coordinator/agent-messaging/http/server.scm @@ -137,13 +137,14 @@ INTERVAL (a time-duration object), otherwise does nothing and returns #f." build-coordinator chunked-request-channel output-hash-channel) + (define plain-metrics-registry + (make-metrics-registry)) + (define gc-metrics-updater - (get-gc-metrics-updater - (build-coordinator-metrics-registry build-coordinator))) + (get-gc-metrics-updater plain-metrics-registry)) - (define port-metrics-updater - (get-port-metrics-updater - (build-coordinator-metrics-registry build-coordinator))) + (define process-metrics-updater + (get-process-metrics-updater plain-metrics-registry)) (define thread-metric (make-gauge-metric @@ -157,7 +158,7 @@ INTERVAL (a time-duration object), otherwise does nothing and returns #f." (call-with-delay-logging gc-metrics-updater) (metric-set thread-metric (length (all-threads))) - (call-with-delay-logging port-metrics-updater) + (call-with-delay-logging process-metrics-updater) (call-with-delay-logging datastore-metrics-updater)) (with-exception-handler @@ -184,7 +185,8 @@ INTERVAL (a time-duration object), otherwise does nothing and returns #f." build-coordinator chunked-request-channel output-hash-channel - update-managed-metrics!))) + update-managed-metrics! + plain-metrics-registry))) #:host host #:port port)) #:unwind? #t)) @@ -614,7 +616,8 @@ INTERVAL (a time-duration object), otherwise does nothing and returns #f." build-coordinator chunked-request-channel output-hash-channel - update-managed-metrics!) + update-managed-metrics! + plain-metrics-registry) (define (authenticated? uuid request) (let* ((authorization-base64 (match (assq-ref (request-headers request) @@ -1015,6 +1018,8 @@ INTERVAL (a time-duration object), otherwise does nothing and returns #f." (lambda (port) (write-metrics (build-coordinator-metrics-registry build-coordinator) + port) + (write-metrics plain-metrics-registry port)))))) (_ (render-json diff --git a/guix-build-coordinator/utils.scm b/guix-build-coordinator/utils.scm index 053730b..a549f20 100644 --- a/guix-build-coordinator/utils.scm +++ b/guix-build-coordinator/utils.scm @@ -96,8 +96,6 @@ running-on-the-hurd? - get-gc-metrics-updater - get-port-metrics-updater get-guix-memory-metrics-updater open-socket-for-uri* @@ -1329,55 +1327,6 @@ again." (set! cached-system (utsname:sysname (uname)))) (string=? cached-system "GNU"))) -(define (get-gc-metrics-updater registry) - (define metrics - `((gc-time-taken - . ,(make-gauge-metric registry "guile_gc_time_taken")) - (heap-size - . ,(make-gauge-metric registry "guile_heap_size")) - (heap-free-size - . ,(make-gauge-metric registry "guile_heap_free_size")) - (heap-total-allocated - . ,(make-gauge-metric registry "guile_heap_total_allocated")) - (heap-allocated-since-gc - . ,(make-gauge-metric registry "guile_allocated_since_gc")) - (protected-objects - . ,(make-gauge-metric registry "guile_gc_protected_objects")) - (gc-times - . ,(make-gauge-metric registry "guile_gc_times")))) - - (lambda () - (let ((stats (gc-stats))) - (for-each - (match-lambda - ((name . metric) - (let ((value (assq-ref stats name))) - (metric-set metric value)))) - metrics)))) - -(define (get-port-metrics-updater registry) - (let ((ports-metric - (make-gauge-metric registry "guile_ports_total")) - (fds-metric - (make-gauge-metric registry "file_descriptors_total"))) - (lambda () - (let ((count 0)) - (port-for-each - (lambda _ - (set! count (+ 1 count)))) - - (metric-set ports-metric count)) - - (metric-set - fds-metric - (length - ;; In theory 'scandir' cannot return #f, but in practice, - ;; we've seen it before. - (or (scandir "/proc/self/fd" - (lambda (file) - (not (member file '("." ".."))))) - '())))))) - (define (get-guix-memory-metrics-updater registry) (define %memoization-tables (@@ (guix memoization) %memoization-tables)) |