aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2023-02-04 10:50:16 +0100
committerChristopher Baines <mail@cbaines.net>2023-02-04 10:50:16 +0100
commit2b686afeaff932dbc45eef8a7324fa6a384537df (patch)
tree19833745a6d19b27af6171aaacf36570cb05f62d
parent66a2862b68087c9bd100b903fe32066d790cbe2c (diff)
downloadnar-herder-2b686afeaff932dbc45eef8a7324fa6a384537df.tar
nar-herder-2b686afeaff932dbc45eef8a7324fa6a384537df.tar.gz
Fix the nar request metrics for cached nars
As these were incorrectly being recording as 404 requests.
-rw-r--r--nar-herder/server.scm43
1 files changed, 27 insertions, 16 deletions
diff --git a/nar-herder/server.scm b/nar-herder/server.scm
index 86e966a..b3c50b6 100644
--- a/nar-herder/server.scm
+++ b/nar-herder/server.scm
@@ -290,22 +290,6 @@
(string->symbol compression)
#f)))
- (when (or narinfo-file-for-compression
- ;; Check for a common compression to avoid lots of
- ;; metrics being generated if compression is random
- compression-symbol)
- (increment-request-metric
- (string-append "nar/"
- compression)
- (if narinfo-file-for-compression "200" "404")
- #:labels
- (if narinfo-file-for-compression
- (let ((system (assq-ref narinfo 'system)))
- (if (string? system)
- `((system . ,system))
- '()))
- '())))
-
(if narinfo-file-for-compression
(begin
(when maybe-trigger-creation-of-compressed-nars
@@ -315,6 +299,16 @@
(assq-ref narinfo 'id)))
#:parallel? #t))
+ (increment-request-metric
+ (string-append "nar/"
+ compression)
+ "200"
+ #:labels
+ (let ((system (assq-ref narinfo 'system)))
+ (if (string? system)
+ `((system . ,system))
+ '())))
+
(values (build-response
#:code 200
#:headers `((X-Accel-Redirect
@@ -329,6 +323,23 @@
database
hash
compression))))
+
+ (when (or cached-narinfo-file
+ ;; Check for a common compression to avoid lots of
+ ;; metrics being generated if compression is random
+ compression-symbol)
+ (increment-request-metric
+ (string-append "nar/"
+ compression)
+ (if cached-narinfo-file "200" "404")
+ #:labels
+ (if cached-narinfo-file
+ (let ((system (assq-ref narinfo 'system)))
+ (if (string? system)
+ `((system . ,system))
+ '()))
+ '())))
+
(if cached-narinfo-file
(values (build-response
#:code 200