client_python icon indicating copy to clipboard operation
client_python copied to clipboard

TypeError in floatToGoString in utils.py

Open klaska-lukas opened this issue 2 years ago • 1 comments

When one PureStorage array controller is failed it reports None value for metric purefa_network_interface_performance. The function floatToGoString fails because it cannot handle None value.

I added two lines in my local copy of "utils.py" to make this function work, so it replaces None value with 0 (zero).

Instead of:

def floatToGoString(d):
   d = float(d)

I use:

def floatToGoString(d):
    if d is None:
        d = 0
    d = float(d)

Below is the error message:

File "/home/pure_exporter/venv/lib/python3.7/site-packages/prometheus_client/utils.py", line 9, in floatToGoString d = float(d) TypeError: ("float() argument must be a string or a number, not 'NoneType'", Metric(purefa_network_interface_performance, FlashArray network interface performance, gauge, , [Sample(name='purefa_network_interface_performance', labels={'interface': 'ct0.eth5', 'dimension': 'rx_bytes'}, value=None, timestamp=None, exemplar=None),

klaska-lukas avatar Apr 05 '23 12:04 klaska-lukas

That may work for your case, but I am not sure it is behavior we want in the library. Do you know how a value of None was set in that metric? That seems like a bug in the collector, or maybe elsewhere in this library. If anything I would expect None to translate to NaN not 0.

csmarchbanks avatar Apr 05 '23 21:04 csmarchbanks