aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2024-05-09 17:38:48 +0100
committerChristopher Baines <mail@cbaines.net>2024-05-09 17:38:48 +0100
commit510144000de70323b4946b1eb9bd31b29aa5bec0 (patch)
treee0dac73905aba615bf940b87f97ac88eb2516883
parent71115bd073d58c48eb4a1d456ac4c89b262799ef (diff)
downloadnar-herder-510144000de70323b4946b1eb9bd31b29aa5bec0.tar
nar-herder-510144000de70323b4946b1eb9bd31b29aa5bec0.tar.gz
Count new files appropriately
Rather than assuming they're not stored.
-rw-r--r--nar-herder/server.scm13
-rw-r--r--nar-herder/storage.scm10
2 files changed, 17 insertions, 6 deletions
diff --git a/nar-herder/server.scm b/nar-herder/server.scm
index f9a8c32..2e2c1e7 100644
--- a/nar-herder/server.scm
+++ b/nar-herder/server.scm
@@ -817,10 +817,15 @@
(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)
+ (apply update-nar-files-metric
+ metrics-registry
+ '()
+ (if (and canonical-storage
+ (file-exists?
+ (string-append canonical-storage
+ (uri-decode file))))
+ '(#:stored-addition-count 1)
+ '(#:not-stored-addition-count 1)))
(when mirror-channel
(spawn-fiber
diff --git a/nar-herder/storage.scm b/nar-herder/storage.scm
index df8ec4d..e85d745 100644
--- a/nar-herder/storage.scm
+++ b/nar-herder/storage.scm
@@ -207,7 +207,8 @@
(define* (update-nar-files-metric metrics-registry
nar-file-counts
#:key fetched-count removed-count
- not-stored-addition-count)
+ not-stored-addition-count
+ stored-addition-count)
;; Avoid incrementing or decrementing the metric if it hasn't been
;; set yet
@@ -255,7 +256,12 @@
(when not-stored-addition-count
(metric-increment nar-files-metric
#:by not-stored-addition-count
- #:label-values '((stored . "false")))))))
+ #:label-values '((stored . "false"))))
+
+ (when stored-addition-count
+ (metric-increment nar-files-metric
+ #:by stored-addition-count
+ #:label-values '((stored . "true")))))))
(define (initialise-storage-metrics database storage-root metrics-registry)
;; Use a database transaction to block changes