prometheus / prometheus/client_python
Metrics without labels missing breaks some codepath
オープン
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 4.4k
- フォーク
- 876
- 平均マージ
- 8日 4時間
- マージ済み PR(30日)
- 1
説明
When initialized without labels, it seems that the resulting metrics objects will lack some instance variables.
Minimal example:
from prometheus_client import Gauge, generate_latest
cc = Gauge("dummy_count", "POC")
if __name__ == '__main__':
cc.set(42)
print(generate_latest().decode()) # OK
cc.clear() # raises
"""
Traceback (most recent call last):
File "prom_example.py", line 10, in <module>
cc.clear() # raises
^^^^^^^^^^
File …/site-packages/prometheus_client/metrics.py", line 213, in clear
with self._lock:
^^^^^^^^^^
AttributeError: 'Gauge' object has no attribute '_lock'
"""
The same code with declared labels will properly clear the metrics data
I came up upon this when adding a new metric and forgetting to add the labels.
(I'm using .clear() to reset the metrics during tests)
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
issue の最小限の例を再現し、その後 metrics.py の 213 行目にある clear メソッドと、ラベルが宣言されていない Gauge の初期化パスを調査してください。宣言されたラベルのないメトリクスで clear() を呼び出しても、報告された AttributeError が発生しなくなっていること、およびラベル付きの場合が引き続き動作することを確認してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- observability
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100