prometheus / prometheus/client_python
Non-stringy label values in MetricFamily metrics cause export-time errors
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 4.4k
- フォーク
- 876
- 平均マージ
- 8日 4時間
- マージ済み PR(30日)
- 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 にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
GaugeMetricFamily と CounterMetricFamily から始め、exposition.py 内の generate_latest を通じて .add_metric() を追跡し、traceback が発生する箇所を確認します。既存の issue #18 に記載された動作を維持しながら、エクスポート時に整数のラベル値が replace() エラーなしで受け入れられることを検証します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- prometheus, python
- 領域
- observability
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100