GNU bug report logs - #43240
[PATCH] Use the #:namespace argument for metric registries

Previous Next

Package: guix-patches;

Reported by: Christopher Baines <mail <at> cbaines.net>

Date: Sun, 6 Sep 2020 12:08:02 UTC

Severity: normal

Tags: patch

Done: Christopher Baines <mail <at> cbaines.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 43240 in the body.
You can then email your comments to 43240 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#43240; Package guix-patches. (Sun, 06 Sep 2020 12:08:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Christopher Baines <mail <at> cbaines.net>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Sun, 06 Sep 2020 12:08:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Christopher Baines <mail <at> cbaines.net>
To: guix-patches <at> gnu.org
Subject: [PATCH] Use the #:namespace argument for metric registries
Date: Sun,  6 Sep 2020 13:07:29 +0100
---
 .../agent-messaging/http.scm                  | 22 +++++--------------
 guix-build-coordinator/coordinator.scm        | 18 ++++++++-------
 guix-build-coordinator/datastore/sqlite.scm   | 11 ++++------
 scripts/guix-build-coordinator.in             |  4 +++-
 4 files changed, 23 insertions(+), 32 deletions(-)

diff --git a/guix-build-coordinator/agent-messaging/http.scm b/guix-build-coordinator/agent-messaging/http.scm
index 1a9a9e9..91b686b 100644
--- a/guix-build-coordinator/agent-messaging/http.scm
+++ b/guix-build-coordinator/agent-messaging/http.scm
@@ -142,9 +142,6 @@ port. Also, the port used can be changed by passing the --port option.\n"
         ""))
 
 (define (base-datastore-metrics-updater build-coordinator)
-  (define namespace
-    "guixbuildcoordinator")
-
   (define datastore
     (build-coordinator-datastore build-coordinator))
 
@@ -152,34 +149,27 @@ port. Also, the port used can be changed by passing the --port option.\n"
     (build-coordinator-metrics-registry build-coordinator))
 
   (let ((builds-total
-         (make-gauge-metric registry
-                            (string-append namespace
-                                           "_builds_total")
+         (make-gauge-metric registry "builds_total"
                             #:labels '(system)))
         (allocated-builds-total
          (make-gauge-metric registry
-                            (string-append namespace
-                                           "_allocated_builds_total")
+                            "allocated_builds_total"
                             #:labels '(agent_id)))
         (build-results-total
          (make-gauge-metric registry
-                            (string-append namespace
-                                           "_build_results_total")
+                            "build_results_total"
                             #:labels '(agent_id result)))
         (setup-failures-total
          (make-gauge-metric registry
-                            (string-append namespace
-                                           "_setup_failures_total")
+                            "setup_failures_total"
                             #:labels '(agent_id reason)))
         (build-allocation-plan-total
          (make-gauge-metric registry
-                            (string-append namespace
-                                           "_build_allocation_plan_total")
+                            "build_allocation_plan_total"
                             #:labels '(agent_id)))
         (unprocessed-hook-events-total
          (make-gauge-metric registry
-                            (string-append namespace
-                                           "_unprocessed_hook_events_total")
+                            "unprocessed_hook_events_total"
                             #:labels '(event))))
     (define (zero-metric-for-agents metric)
       (for-each (lambda (agent-details)
diff --git a/guix-build-coordinator/coordinator.scm b/guix-build-coordinator/coordinator.scm
index 33b5afe..c8727c8 100644
--- a/guix-build-coordinator/coordinator.scm
+++ b/guix-build-coordinator/coordinator.scm
@@ -68,7 +68,9 @@
                         set-build-coordinator-allocator-thread!))
 
 (define* (make-build-coordinator #:key datastore hooks
-                                 (metrics-registry (make-metrics-registry))
+                                 (metrics-registry (make-metrics-registry
+                                                    #:namespace
+                                                    "guixbuildcoordinator_"))
                                  (allocation-strategy
                                   basic-build-allocation-strategy))
   (let ((build-coordinator
@@ -198,12 +200,12 @@
   (define success-counter-metric
     (make-counter-metric
      (build-coordinator-metrics-registry build-coordinator)
-     "guixbuildcoordinator_allocator_allocations_total"))
+     "allocator_allocations_total"))
 
   (define failure-counter-metric
     (make-counter-metric
      (build-coordinator-metrics-registry build-coordinator)
-     "guixbuildcoordinator_allocator_failures_total"))
+     "allocator_failures_total"))
 
   (define (allocate-builds-loop)
     (while #t
@@ -215,7 +217,7 @@
             (atomic-box-set! allocation-needed #f)))
         (call-with-duration-metric
          (build-coordinator-metrics-registry build-coordinator)
-         "guixbuildcoordinator_allocate_builds_duration_seconds"
+         "allocate_builds_duration_seconds"
          (lambda ()
            (with-exception-handler
                (lambda (exn)
@@ -270,13 +272,13 @@
   (define success-counter-metric
     (make-counter-metric
      (build-coordinator-metrics-registry build-coordinator)
-     "guixbuildcoordinator_hook_success_total"
+     "hook_success_total"
      #:labels '(event)))
 
   (define failure-counter-metric
     (make-counter-metric
      (build-coordinator-metrics-registry build-coordinator)
-     "guixbuildcoordinator_hook_failure_total"
+     "hook_failure_total"
      #:labels '(event)))
 
   (define (process-events event-name handler)
@@ -330,7 +332,7 @@
 (define (fetch-builds build-coordinator agent systems count)
   (call-with-duration-metric
    (build-coordinator-metrics-registry build-coordinator)
-   "guixbuildcoordinator_coordinator_fetch_builds_duration_seconds"
+   "coordinator_fetch_builds_duration_seconds"
    (lambda ()
      (let ((update-made (datastore-update-agent-requested-systems
                          (build-coordinator-datastore build-coordinator)
@@ -393,7 +395,7 @@
 
   (call-with-duration-metric
    (build-coordinator-metrics-registry build-coordinator)
-   "guixbuildcoordinator_coordinator_handle_build_result_duration_seconds"
+   "coordinator_handle_build_result_duration_seconds"
    (lambda ()
      (let* ((result (assoc-ref result-json "result"))
             (success? (string=? result "success")))
diff --git a/guix-build-coordinator/datastore/sqlite.scm b/guix-build-coordinator/datastore/sqlite.scm
index f3e3bbf..13d9ec7 100644
--- a/guix-build-coordinator/datastore/sqlite.scm
+++ b/guix-build-coordinator/datastore/sqlite.scm
@@ -126,13 +126,10 @@
   (define registry (slot-ref datastore 'metrics-registry))
 
   (if registry
-      (let* ((namespaced-metric-name
-              (string-append "guixbuildcoordinator_" metric-name))
-             (metric
-              (or (metrics-registry-fetch-metric registry namespaced-metric-name)
-                  (make-histogram-metric
-                   registry
-                   namespaced-metric-name)))
+      (let* ((metric
+              (or (metrics-registry-fetch-metric registry metric-name)
+                  (make-histogram-metric registry
+                                         metric-name)))
              (start-time (current-time)))
         (let ((result (thunk)))
           (metric-observe metric (- (current-time) start-time))
diff --git a/scripts/guix-build-coordinator.in b/scripts/guix-build-coordinator.in
index 87982c0..f4c5048 100644
--- a/scripts/guix-build-coordinator.in
+++ b/scripts/guix-build-coordinator.in
@@ -434,7 +434,9 @@ processed?:      ~A
                                (append %service-option-defaults
                                        %base-option-defaults)
                                arguments))
-          (metrics-registry (make-metrics-registry))
+          (metrics-registry (make-metrics-registry
+                             #:namespace
+                             "guixbuildcoordinator_"))
           (datastore (database-uri->datastore
                       (assq-ref opts 'database)
                       #:metrics-registry metrics-registry))
-- 
2.28.0





bug closed, send any further explanations to 43240 <at> debbugs.gnu.org and Christopher Baines <mail <at> cbaines.net> Request was from Christopher Baines <mail <at> cbaines.net> to control <at> debbugs.gnu.org. (Sun, 06 Sep 2020 13:16:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Christopher Baines <mail <at> cbaines.net> to control <at> debbugs.gnu.org. (Sun, 06 Sep 2020 13:16:02 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 345 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.