aboutsummaryrefslogtreecommitdiff
path: root/prometheus.scm
diff options
context:
space:
mode:
Diffstat (limited to 'prometheus.scm')
-rw-r--r--prometheus.scm64
1 files changed, 38 insertions, 26 deletions
diff --git a/prometheus.scm b/prometheus.scm
index 024f578..d6889e1 100644
--- a/prometheus.scm
+++ b/prometheus.scm
@@ -367,30 +367,42 @@ so that it can receive and store the metric values."
(hash-for-each
(lambda (name metric)
- (hash-for-each
- (lambda (label-values value)
- (simple-format
- port
- "~A~A~A ~A\n"
- (or (and=> (metrics-registry-namespace registry)
- (lambda (namespace)
- (string-append namespace "_")))
- "")
- name
- (if (null? label-values)
- ""
- (string-append
- "{"
- (string-join (map
- (match-lambda
- ((label . value)
- (simple-format
- #f
- "~A=\"~A\""
- label value)))
- label-values)
- ",")
- "}"))
- value))
- (metric-values metric)))
+ (let ((full-name
+ (string-append
+ (or (and=> (metrics-registry-namespace registry)
+ (lambda (namespace)
+ (string-append namespace "_")))
+ "")
+ name)))
+
+ (and=> (metric-docstring metric)
+ (lambda (docstring)
+ (simple-format
+ port
+ "# HELP ~A ~A\n"
+ full-name
+ docstring)))
+
+ (hash-for-each
+ (lambda (label-values value)
+ (simple-format
+ port
+ "~A~A ~A\n"
+ full-name
+ (if (null? label-values)
+ ""
+ (string-append
+ "{"
+ (string-join (map
+ (match-lambda
+ ((label . value)
+ (simple-format
+ #f
+ "~A=\"~A\""
+ label value)))
+ label-values)
+ ",")
+ "}"))
+ value))
+ (metric-values metric))))
(metrics-registry-metrics-hash registry)))