metrics: influx: preprare value: rename $quote to $force_quote

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>
This commit is contained in:
Thomas Lamprecht 2022-01-28 11:06:25 +01:00
parent 9d37535bec
commit 84502c7d1f

View File

@ -278,6 +278,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) {
@ -333,10 +334,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;