diff options
author | Christopher Baines <mail@cbaines.net> | 2023-09-11 13:52:02 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2023-09-12 13:11:00 +0100 |
commit | 53044617ceec957894df239958ef83414f809740 (patch) | |
tree | ef3922a1c7661dd9f1f7641567d7835974724d0f | |
parent | 97981d0c30116acf3fb5bc3e3cfa5cca90109911 (diff) | |
download | nar-herder-53044617ceec957894df239958ef83414f809740.tar nar-herder-53044617ceec957894df239958ef83414f809740.tar.gz |
Cleanup handling of the nar_files_total metric
-rw-r--r-- | nar-herder/storage.scm | 42 |
1 files changed, 11 insertions, 31 deletions
diff --git a/nar-herder/storage.scm b/nar-herder/storage.scm index d007a48..d5fae15 100644 --- a/nar-herder/storage.scm +++ b/nar-herder/storage.scm @@ -169,13 +169,6 @@ (define* (get-nar-files database storage-root metrics-registry #:key stored?) - (define nar-files-metric - (or (metrics-registry-fetch-metric metrics-registry - "nar_files_total") - (make-gauge-metric metrics-registry - "nar_files_total" - #:labels '(stored)))) - (let* ((index (index-storage database storage-root)) (selected-files (filter @@ -188,12 +181,13 @@ (all-files-count (length (assq-ref index 'narinfo-files)))) - (metric-set nar-files-metric - selected-files-count - #:label-values `((stored . ,(if stored? "true" "false")))) - (metric-set nar-files-metric - (- all-files-count selected-files-count) - #:label-values `((stored . ,(if stored? "false" "true"))))) + (update-nar-files-metric + metrics-registry + (list + (cons (if stored? 'stored 'not-stored) + selected-files-count) + (cons (if stored? 'not-stored 'stored) + (- all-files-count selected-files-count))))) selected-files)) @@ -383,13 +377,6 @@ When VERIFY-CERTIFICATE? is true, verify HTTPS server certificates." (make-gauge-metric metrics-registry "storage_size_bytes")) - (define nar-files-metric - (or (metrics-registry-fetch-metric metrics-registry - "nar_files_total") - (make-gauge-metric metrics-registry - "nar_files_total" - #:labels '(stored)))) - (define (check-removal-criteria nar criteria) (define narinfo (database-select-narinfo-for-file database (assq-ref nar 'url))) @@ -528,13 +515,6 @@ When VERIFY-CERTIFICATE? is true, verify HTTPS server certificates." (make-gauge-metric metrics-registry "storage_size_bytes")) - (define nar-files-metric - (or (metrics-registry-fetch-metric metrics-registry - "nar_files_total") - (make-gauge-metric metrics-registry - "nar_files_total" - #:labels '(stored)))) - (define (fetch-file file) (let* ((string-url (string-append mirror file)) @@ -585,10 +565,10 @@ When VERIFY-CERTIFICATE? is true, verify HTTPS server certificates." (rename-file tmp-file-name destination-file-name) - (metric-increment nar-files-metric - #:label-values '((stored . "true"))) - (metric-decrement nar-files-metric - #:label-values '((stored . "false"))))) + (update-nar-files-metric + metrics-registry + '() + #:fetched-count 1))) (define (download-nars initial-storage-size) ;; If there's free space, then consider downloading missing nars |