Support outputting docstrings

This commit is contained in:
Christopher Baines 2020-11-29 08:49:46 +00:00
parent 8980f39baf
commit 826704723a

View file

@ -367,16 +367,28 @@ so that it can receive and store the metric values."
(hash-for-each (hash-for-each
(lambda (name metric) (lambda (name metric)
(hash-for-each (let ((full-name
(lambda (label-values value) (string-append
(simple-format
port
"~A~A~A ~A\n"
(or (and=> (metrics-registry-namespace registry) (or (and=> (metrics-registry-namespace registry)
(lambda (namespace) (lambda (namespace)
(string-append namespace "_"))) (string-append namespace "_")))
"") "")
name 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) (if (null? label-values)
"" ""
(string-append (string-append
@ -392,5 +404,5 @@ so that it can receive and store the metric values."
",") ",")
"}")) "}"))
value)) value))
(metric-values metric))) (metric-values metric))))
(metrics-registry-metrics-hash registry))) (metrics-registry-metrics-hash registry)))