prometheus / prometheus/client_python
TypeError in floatToGoString in utils.py
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 4.4k
- 派生
- 876
- 平均合并
- 8 天 4 小时
- 30 天内合并 PR
- 1
描述
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),
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 utils.py 中的 floatToGoString 开始,使用 None 值重现该失败。查看此工具周围现有的测试,然后添加回归测试,表明 None 会被作为零处理,同时普通数值输入仍能正常工作。当报告的指标可以在不出现 TypeError 的情况下序列化时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- observability
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 45/100