Expose resource pool stats

This commit is contained in:
Christopher Baines 2023-07-09 18:06:57 +01:00
parent 899bd1387e
commit 75ef4cffd3
2 changed files with 52 additions and 20 deletions

View file

@ -174,6 +174,24 @@
#:labels '(table column))))
pg-stats-fields))
(resource-pools
`(("normal" . ,(connection-pool))
("reserved" . ,(reserved-connection-pool))))
(resource-pool-metrics
`((resources . ,(make-gauge-metric
registry
"resource_pool_resources_total"
#:labels '(pool_name)))
(available . ,(make-gauge-metric
registry
"resource_pool_resources_available_total"
#:labels '(pool_name)))
(waiters . ,(make-gauge-metric
registry
"resource_pool_waiters_total"
#:labels '(pool_name)))))
(gc-metrics-updater
(get-gc-metrics-updater registry)))
@ -214,6 +232,20 @@
(reserved-connection-pool)
select-load-new-guix-revision-job-metrics)))
(for-each
(match-lambda
((name . pool)
(for-each
(match-lambda
((stat . value)
(metric-set
(assq-ref resource-pool-metrics stat)
value
#:label-values
`((pool_name . ,name)))))
(resource-pool-stats pool))))
resource-pools)
(for-each (match-lambda
((name tablespace row-estimate
table-bytes toast-bytes)

View file

@ -68,9 +68,6 @@
(define registry
(make-metrics-registry #:namespace "guixdataservice"))
(define render-metrics
(make-render-metrics registry))
(%database-metrics-registry registry)
(let ((finished? (make-condition)))
@ -97,6 +94,9 @@
(resource-pool-default-timeout 10))
(let ((render-metrics
(make-render-metrics registry)))
(with-exception-handler
(lambda (exn)
(simple-format
@ -117,6 +117,6 @@ port. Also, the port used can be changed by passing the --port option.\n"
render-metrics))
#:host host
#:port port))
#:unwind? #t))
#:unwind? #t)))
(wait finished?))))
finished?)))