diff options
-rw-r--r-- | nar-herder/mirror.scm | 20 | ||||
-rw-r--r-- | scripts/nar-herder.in | 3 |
2 files changed, 20 insertions, 3 deletions
diff --git a/nar-herder/mirror.scm b/nar-herder/mirror.scm index 2ef84fc..11f7136 100644 --- a/nar-herder/mirror.scm +++ b/nar-herder/mirror.scm @@ -26,6 +26,7 @@ #:use-module (web uri) #:use-module (web client) #:use-module (web response) + #:use-module (prometheus) #:use-module (logging logger) #:use-module (json) #:use-module (guix narinfo) @@ -33,7 +34,14 @@ #:use-module (nar-herder database) #:export (start-fetch-changes-thread)) -(define (start-fetch-changes-thread database mirror) +(define (start-fetch-changes-thread database 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)) @@ -105,7 +113,15 @@ narinfo #:change-datetime (assq-ref change-details - 'datetime)))) + '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")))))) (else (error "unimplemented")))))) recent-changes)) diff --git a/scripts/nar-herder.in b/scripts/nar-herder.in index 95de7db..c572106 100644 --- a/scripts/nar-herder.in +++ b/scripts/nar-herder.in @@ -358,7 +358,8 @@ (and=> (assq-ref opts 'mirror) (lambda (mirror) - (start-fetch-changes-thread database mirror) + (start-fetch-changes-thread database mirror + metrics-registry) (when (assq-ref opts 'storage) (start-mirroring-thread database |