diff options
author | Christopher Baines <mail@cbaines.net> | 2024-04-27 17:03:35 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2024-04-27 17:03:35 +0100 |
commit | 820697c47cdc7500b0e1e5e49b8e425123b289cb (patch) | |
tree | ec5d9278e3c0adc1a1d9ddac23346c4746182ad4 | |
parent | 13264c3478cac669fc12c129e9f4dd1bbc97c723 (diff) | |
download | nar-herder-820697c47cdc7500b0e1e5e49b8e425123b289cb.tar nar-herder-820697c47cdc7500b0e1e5e49b8e425123b289cb.tar.gz |
Fix the nar_files metric not being updated correctly
-rw-r--r-- | nar-herder/server.scm | 11 | ||||
-rw-r--r-- | nar-herder/storage.scm | 14 |
2 files changed, 18 insertions, 7 deletions
diff --git a/nar-herder/server.scm b/nar-herder/server.scm index a025fa3..f9a8c32 100644 --- a/nar-herder/server.scm +++ b/nar-herder/server.scm @@ -817,9 +817,16 @@ (lambda () (match (get-message addition-channel) (('addition file) + ;; TODO Check if the file is actually not stored + (update-nar-files-metric metrics-registry + '() + #:not-stored-addition-count 1) + (when mirror-channel - (put-message mirror-channel - `(fetch ,file))) + (spawn-fiber + (lambda () + (put-message mirror-channel + `(fetch ,file))))) (when removal-channel (spawn-fiber (lambda () diff --git a/nar-herder/storage.scm b/nar-herder/storage.scm index 53793ac..7d3ee8a 100644 --- a/nar-herder/storage.scm +++ b/nar-herder/storage.scm @@ -41,6 +41,7 @@ remove-nar-files-by-hash initialise-storage-metrics + update-nar-files-metric check-storage removal-channel-remove-nar-from-storage @@ -203,7 +204,8 @@ (define* (update-nar-files-metric metrics-registry nar-file-counts - #:key fetched-count removed-count) + #:key fetched-count removed-count + not-stored-addition-count) ;; Avoid incrementing or decrementing the metric if it hasn't been ;; set yet @@ -246,6 +248,11 @@ #:label-values '((stored . "true"))) (metric-increment nar-files-metric #:by removed-count + #:label-values '((stored . "false")))) + + (when not-stored-addition-count + (metric-increment nar-files-metric + #:by not-stored-addition-count #:label-values '((stored . "false"))))))) (define (initialise-storage-metrics database storage-root metrics-registry) @@ -738,10 +745,7 @@ When VERIFY-CERTIFICATE? is true, verify HTTPS server certificates." (lambda (exn) (log-msg 'ERROR "failed to mirror " file ": " exn)) (lambda () - (fetch-file file) - (update-nar-files-metric metrics-registry - '() - #:fetched-count 1)) + (fetch-file file)) #:unwind? #t)))))) (spawn-fiber |