diff options
author | Christopher Baines <mail@cbaines.net> | 2020-09-20 19:13:23 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2020-09-20 19:13:23 +0100 |
commit | af2e12a9ef529789017caaba8c866b13f9c34067 (patch) | |
tree | 0c033fa98404cd1d0b99f57a1585c30088ca71bb /guix-data-service | |
parent | fd3ba489d986d4f348c675cd63b1abd191f1aa86 (diff) | |
download | data-service-af2e12a9ef529789017caaba8c866b13f9c34067.tar data-service-af2e12a9ef529789017caaba8c866b13f9c34067.tar.gz |
Add some new metrics about load new revision jobs
Diffstat (limited to 'guix-data-service')
-rw-r--r-- | guix-data-service/jobs/load-new-guix-revision.scm | 20 | ||||
-rw-r--r-- | guix-data-service/web/controller.scm | 16 |
2 files changed, 36 insertions, 0 deletions
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)))) |