prometheus / prometheus/client_python
Non-stringy label values in MetricFamily metrics cause export-time errors
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 4.4k
- 派生
- 876
- 平均合并
- 8 天 4 小时
- 30 天内合并 PR
- 1
描述
This is very similar to #18 only I'm using the GaugeMetricFamily/CounterMetricFamily interface, otherwise the symptoms are the same. I'm using the default pypi version (which I think is 0.2.0).
I was inadvertently passing in ints for a couple of the label values in .add_metric(), which results in a 500 error on export and the following traceback. Wrapping a str() around the values makes this go away. Coercing these values as was done in the fix for #18 seems like the right thing to do here as well.
Traceback (most recent call last):
File "/usr/local/lib/python3.6/socketserver.py", line 639, in process_request_thread
self.finish_request(request, client_address)
File "/usr/local/lib/python3.6/socketserver.py", line 361, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/local/lib/python3.6/socketserver.py", line 696, in __init__
self.handle()
File "/usr/local/lib/python3.6/http/server.py", line 418, in handle
self.handle_one_request()
File "/usr/local/lib/python3.6/http/server.py", line 406, in handle_one_request
method()
File "/usr/local/lib/python3.6/site-packages/prometheus_client/exposition.py", line 95, in do_GET
output = generate_latest(registry)
File "/usr/local/lib/python3.6/site-packages/prometheus_client/exposition.py", line 78, in generate_latest
for k, v in sorted(labels.items())]))
File "/usr/local/lib/python3.6/site-packages/prometheus_client/exposition.py", line 78, in <listcomp>
for k, v in sorted(labels.items())]))
AttributeError: 'int' object has no attribute 'replace'
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 GaugeMetricFamily 和 CounterMetricFamily 开始,跟踪 exposition.py 中的 generate_latest 内的 .add_metric(),直到 traceback 发生的位置。验证整数标签值在导出期间能够被接受且不会出现 replace() 错误,同时保留 issue #18 中描述的现有行为。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- prometheus, python
- 领域
- observability
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100