]> git.proxmox.com Git - pve-manager.git/commitdiff
metrics: influx: preprare value: rename $quote to $force_quote
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 28 Jan 2022 10:06:25 +0000 (11:06 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 14 Mar 2022 09:44:20 +0000 (10:44 +0100)
to avoid implying that it's *only* quoted if that parameter is
truthy.

Also, check the boolean before looks_like_number call, as that is
more expensive to do.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
(cherry picked from commit b8608c53e773fad60d0008b0f1937e0cc5dd1c34)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/Status/InfluxDB.pm

index 0c6c88f38ebda36cf31880943f8b3d5c862bdc0a..c7d6819fd640dede480ddc8015920e52aeb93733 100644 (file)
@@ -252,6 +252,7 @@ sub build_influxdb_payload {
 
     # 'abc' and '123' are both valid hostnames, that confuses influx's type detection
     my $to_quote = { name => 1 };
+
     my @values = ();
 
     foreach my $key (sort keys %$data) {
@@ -307,10 +308,10 @@ sub get_recursive_values {
 }
 
 sub prepare_value {
-    my ($value, $quote) = @_;
+    my ($value, $force_quote) = @_;
 
     # don't treat value like a number if quote is 1
-    if (looks_like_number($value) && !$quote) {
+    if (!$force_quote && looks_like_number($value)) {
        if (isnan($value) || isinf($value)) {
            # we cannot send influxdb NaN or Inf
            return undef;