would be nice if `Info.info()` accepted non-`str` types in the given `dict`
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.
The problem with accepting non-string values is that it is easy to create a footgun. Numbers are likely to change over the lifetime of a process, which will end up with encoding something like the controller temperature in your example into many different time series. Enforcing that only string values provides an option to correct any mistakes, and if they know what they are doing they can cast the number or other type into a string.