guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

03/03: Add some new metrics about load new revision jobs


From: Christopher Baines
Subject: 03/03: Add some new metrics about load new revision jobs
Date: Sun, 20 Sep 2020 14:14:11 -0400 (EDT)

cbaines pushed a commit to branch master
in repository data-service.

commit af2e12a9ef529789017caaba8c866b13f9c34067
Author: Christopher Baines <mail@cbaines.net>
AuthorDate: Sun Sep 20 19:13:23 2020 +0100

    Add some new metrics about load new revision jobs
---
 guix-data-service/jobs/load-new-guix-revision.scm | 20 ++++++++++++++++++++
 guix-data-service/web/controller.scm              | 16 ++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/guix-data-service/jobs/load-new-guix-revision.scm 
b/guix-data-service/jobs/load-new-guix-revision.scm
index d9fc0dc..1e4a17e 100644
--- a/guix-data-service/jobs/load-new-guix-revision.scm
+++ b/guix-data-service/jobs/load-new-guix-revision.scm
@@ -62,6 +62,7 @@
             combine-log-parts!
             fetch-unlocked-jobs
             process-load-new-guix-revision-job
+            select-load-new-guix-revision-job-metrics
             select-job-for-commit
             select-jobs-and-events
             select-recent-job-events
@@ -1327,6 +1328,25 @@ RETURNING id;")
      result)
     (() #f)))
 
+(define (select-load-new-guix-revision-job-metrics conn)
+  (define query
+    "
+SELECT COALESCE(git_repositories.label, git_repositories.url) AS 
repository_label,
+       succeeded_at IS NOT NULL AS completed,
+       COUNT(*)
+FROM load_new_guix_revision_jobs
+INNER JOIN git_repositories
+  ON load_new_guix_revision_jobs.git_repository_id =
+      git_repositories.id
+GROUP BY 1, 2")
+
+  (map (match-lambda
+         ((label completed count)
+          (list label
+                (string=? "t" completed)
+                (string->number count))))
+       (exec-query conn query)))
+
 (define (select-job-for-commit conn commit)
   (let ((result
          (exec-query
diff --git a/guix-data-service/web/controller.scm 
b/guix-data-service/web/controller.scm
index 44d57c1..0e0150e 100644
--- a/guix-data-service/web/controller.scm
+++ b/guix-data-service/web/controller.scm
@@ -89,6 +89,12 @@
          (revisions-count-metric    (make-gauge-metric registry
                                                        "revision_count"))
 
+         (load-new-guix-revision-job-count (make-gauge-metric
+                                            registry
+                                            "load_new_guix_revision_job_count"
+                                            #:labels '(repository_label
+                                                       completed)))
+
          (table-row-estimate-metric (make-gauge-metric registry
                                                        "table_row_estimate"
                                                        #:labels '(name)))
@@ -123,6 +129,16 @@
       (metric-set revisions-count-metric
                   (count-guix-revisions conn))
 
+      (for-each (match-lambda
+                  ((repository-label completed count)
+                   (metric-set
+                    load-new-guix-revision-job-count
+                    count
+                    #:label-values
+                    `((repository_label . ,repository-label)
+                      (completed        . ,(if completed "yes" "no"))))))
+                (select-load-new-guix-revision-job-metrics conn))
+
       (list (build-response
              #:code 200
              #:headers '((content-type . (text/plain))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]