From eb8a6131096ac64e0ce014bba9edf7644e3e1b39 Mon Sep 17 00:00:00 2001 From: dmitry krokhin Date: Mon, 20 Feb 2023 11:33:26 +0300 Subject: [PATCH] prometheus exporter decimal and thousand separator configuration --- src/Metrics/Exporter/PrometheusExporter.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Metrics/Exporter/PrometheusExporter.php b/src/Metrics/Exporter/PrometheusExporter.php index 576e605..8c63784 100644 --- a/src/Metrics/Exporter/PrometheusExporter.php +++ b/src/Metrics/Exporter/PrometheusExporter.php @@ -11,6 +11,8 @@ class PrometheusExporter extends Exporter { private int $decimals = 3; + public string $thousandsSeparator = ""; + public string $decimalSeparator = "."; public function setDecimals(int $decimals): self { @@ -45,7 +47,7 @@ public function toString(string $prefix = '', array $labels = []): string $value = $row['value']; if (is_float($value)) { - $value = number_format($value, $this->decimals); + $value = number_format($value, $this->decimals, $this->decimalSeparator, $this->thousandsSeparator); } $result[$key . '_'] = sprintf('%s %s', $key, $value);