Skip to content

Commit

Permalink
prometheus exporter decimal and thousand separator configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
nekufa committed Feb 20, 2023
1 parent 92fd10c commit eb8a613
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Metrics/Exporter/PrometheusExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
class PrometheusExporter extends Exporter
{
private int $decimals = 3;
public string $thousandsSeparator = "";
public string $decimalSeparator = ".";

public function setDecimals(int $decimals): self
{
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit eb8a613

Please sign in to comment.