Hey.
Right now, when one feeds a dict into Info.info()that contains values that are notstr` one get's an exception, like:
AttributeError: ("'float' object has no attribute 'replace'", Metric(smart_array, blafasl, info, , [Sample(name='smart_array_info', labels={'slot': '0', 'serial_number': 'xxx', 'controller_status': 'OK', 'hardware_revision': 'B', 'firmware_version': '6.60', 'rebuild_priority': 'High', 'cache_status': 'OK', 'battery_capacitor_status': 'OK', 'controller_temperature_celsius': 49.0, 'cache_module_temperature_celsius': 38.0, 'model': 'Smart Array P840ar'}, value=1.0, timestamp=None, exemplar=None)]))
IMO it woud be nice if that would accept at least other base Python types like int, float and bool and convert these automatically do a suitable representation (which is obvious, I guess, expect perhaps for bool , where one could go by 0/1 (guess that should be it) or True/False/etc.).
Stripping off \n and the likes wouldn't be needed for those types anyway.
Perhaps one could make it generic? Only if the value is an instance of str, try to .replace(...) in all other cases, make a str() out of it?
Maybe with an exception for bool if 0/1 shall be used.
Cheers,
Chris.
Hey.
Right now, when one feeds a
dictinto Info.info()that contains values that are notstr` one get's an exception, like:IMO it woud be nice if that would accept at least other base Python types like
int,floatandbooland convert these automatically do a suitable representation (which is obvious, I guess, expect perhaps forbool, where one could go by0/1(guess that should be it) orTrue/False/etc.).Stripping off
\nand the likes wouldn't be needed for those types anyway.Perhaps one could make it generic? Only if the value is an instance of
str, try to.replace(...)in all other cases, make astr()out of it?Maybe with an exception for
boolif0/1shall be used.Cheers,
Chris.