diff options
author | Christopher Baines <mail@cbaines.net> | 2023-11-12 13:39:14 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2023-11-12 13:39:14 +0000 |
commit | 4aaf902eb45b3a4c1003f854bda56c516fdf4f5b (patch) | |
tree | 28498f3cb5fbf7c99060d6886fd78fe2ea90d1c5 | |
parent | c1b8fe176edfe43ed007e76aa00b14de11924f5a (diff) | |
download | prometheus-4aaf902eb45b3a4c1003f854bda56c516fdf4f5b.tar prometheus-4aaf902eb45b3a4c1003f854bda56c516fdf4f5b.tar.gz |
Add get-gc-metrics-updater
-rw-r--r-- | prometheus.scm | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/prometheus.scm b/prometheus.scm index 04f24d8..447ba08 100644 --- a/prometheus.scm +++ b/prometheus.scm @@ -44,7 +44,9 @@ metric-set metric-observe - call-with-duration-metric)) + call-with-duration-metric + + get-gc-metrics-updater)) (define-record-type <metrics-registry> (make-metrics-registry-record metrics-hash namespace) @@ -558,3 +560,28 @@ This procedure takes care of atomically replacing the file." (lambda (key . args) (false-if-exception (delete-file template)))))) +(define (get-gc-metrics-updater registry) + (define metrics + `((gc-time-taken + . ,(make-gauge-metric registry "guile_gc_time_taken")) + (heap-size + . ,(make-gauge-metric registry "guile_heap_size")) + (heap-free-size + . ,(make-gauge-metric registry "guile_heap_free_size")) + (heap-total-allocated + . ,(make-gauge-metric registry "guile_heap_total_allocated")) + (heap-allocated-since-gc + . ,(make-gauge-metric registry "guile_allocated_since_gc")) + (protected-objects + . ,(make-gauge-metric registry "guile_gc_protected_objects")) + (gc-times + . ,(make-gauge-metric registry "guile_gc_times")))) + + (lambda () + (let ((stats (gc-stats))) + (for-each + (match-lambda + ((name . metric) + (let ((value (assq-ref stats name))) + (metric-set metric value)))) + metrics)))) |