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,30 +367,42 @@ 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 (or (and=> (metrics-registry-namespace registry)
port (lambda (namespace)
"~A~A~A ~A\n" (string-append namespace "_")))
(or (and=> (metrics-registry-namespace registry) "")
(lambda (namespace) name)))
(string-append namespace "_")))
"") (and=> (metric-docstring metric)
name (lambda (docstring)
(if (null? label-values) (simple-format
"" port
(string-append "# HELP ~A ~A\n"
"{" full-name
(string-join (map docstring)))
(match-lambda
((label . value) (hash-for-each
(simple-format (lambda (label-values value)
#f (simple-format
"~A=\"~A\"" port
label value))) "~A~A ~A\n"
label-values) full-name
",") (if (null? label-values)
"}")) ""
value)) (string-append
(metric-values metric))) "{"
(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))) (metrics-registry-metrics-hash registry)))