aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nar-herder/mirror.scm32
1 files changed, 15 insertions, 17 deletions
diff --git a/nar-herder/mirror.scm b/nar-herder/mirror.scm
index 4ccf878..874a59b 100644
--- a/nar-herder/mirror.scm
+++ b/nar-herder/mirror.scm
@@ -40,13 +40,6 @@
(define (start-fetch-changes-fiber database storage-root
mirror metrics-registry)
- (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 (request-recent-changes)
(define latest-recent-change
(database-select-latest-recent-change-datetime database))
@@ -127,13 +120,21 @@
(assq-ref change-details
'datetime))
- (let ((new-files-count (length (narinfo-uris narinfo))))
- (metric-increment nar-files-metric
- #:by new-files-count
- ;; TODO This should be
- ;; checked, rather than
- ;; assumed to be false
- #:label-values '((stored . "false"))))))
+ (and=> (metrics-registry-fetch-metric metrics-registry
+ "nar_files_total")
+ (lambda (metric)
+ ;; Just update this metric if it
+ ;; exists, since if it does, it
+ ;; should be set to a value
+ (let ((new-files-count
+ (length (narinfo-uris narinfo))))
+ (metric-increment
+ metric
+ #:by new-files-count
+ ;; TODO This should be
+ ;; checked, rather than
+ ;; assumed to be false
+ #:label-values '((stored . "false"))))))))
((string=? change "removal")
(let ((store-path (assq-ref change-details 'data)))
(log-msg 'INFO "processing removal change for "
@@ -163,9 +164,6 @@
(spawn-fiber
(lambda ()
- ;; This will initialise the nar_files_total metric
- (get-nar-files database storage-root metrics-registry)
-
(while #t
(with-exception-handler
(lambda (exn)