From 2549c482fb04db84481d595f0bf99a1c8bb97c4c Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sat, 5 Dec 2020 17:52:31 +0000 Subject: Fix issues with outputting values Ensure numbers are formatted as floats. --- prometheus.scm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/prometheus.scm b/prometheus.scm index 464b546..68a3fa2 100644 --- a/prometheus.scm +++ b/prometheus.scm @@ -22,6 +22,7 @@ #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) #:use-module (ice-9 match) + #:use-module (ice-9 format) #:use-module (ice-9 threads) #:use-module (ice-9 exceptions) #:export (make-metrics-registry @@ -404,9 +405,9 @@ so that it can receive and store the metric values." (hash-for-each (lambda (label-values value) - (simple-format + (format port - "~A~A ~A\n" + "~a~a ~f\n" full-name (if (null? label-values) "" @@ -414,10 +415,15 @@ so that it can receive and store the metric values." "{" (string-join (map (match-lambda + ((label . (? number? value)) + (format + #f + "~a=\"~f\"" + label value)) ((label . value) - (simple-format + (format #f - "~A=\"~A\"" + "~a=\"~a\"" label value))) label-values) ",") -- cgit v1.2.3