Add public, read-only access to label names, label values of any metric
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 38/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- prometheus, python
調査の方向性
MetricWrapperBase から始め、issue に記載されている _metric、_labelnames、_lock、collect()、remove() の既存の動作を確認します。ラベル名とラベル値タプルへの公開読み取り専用アクセスを定義し、公開される値とスレッドセーフな読み取り動作を確認するテストを追加します。
索引モデルが issue の本文から書いたものです。
説明
Hi,
I am currently working on Prometheus metrics for Celery workers in Flower project and we use this wonderful library :) - thx for your work on it!
One issue I came across is lack of direct access to metric's labelnames and labelvalues.
I think easiest is to give you an example how it is used/why it is needed.
We have multiple celery workers in a kubernetes cluster, they are monitored by Flower which generates Prometheus metrics.
Now the pods in k8s can die or be replaced if a new release of our software is deployed.
The problem with that then is that the final reading for each metric for that pod is retained forever and it shows in grafana forever.
We want to remove any tuples of label values which contain a celery worker name that is deemed offline/dead.
I used a semi-hack (https://github.com/mher/flower/pull/1135) and get those label values through metric.collect(), and from that iterate over samples and the labels in them and then if they contain an offline worker I remove the whole tuple from a given metric by calling metric.remove(*labelvalues_containg_dead_worker)
There could be a better way - access metric._metric.keys() in a thread safe and read-only way.
So I propose to add to MetricWrapperBase a read only property, say all_label_values (name to be improved, suggestions welcome :))
@property
def all_label_values(self) -> List[Tuple[str, ...]]:
with self._lock:
all_label_values = list(self._metric.keys().copy())
return all_label_values
I think I am also badly missing access to actual labelnames set for the given metric to know at which position a label with a given name will be in the labelvalues.
Could kill 2 birds with one stone then and add:
@property
def labelnames(self) -> Tuple[str, ...]:
return self._labelnames
Please let me know if such a change is acceptable and if I am missing any nuances.
If you think you would be ok merging it I will make a PR with tests soon.
Cheers,
Tom
- 主要言語
- Python
- スター
- 4.4k
- フォーク
- 876
- 平均マージ
- 8日 4時間
- マージ済み PR(30日)
- 1
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
prometheus/client_python のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
prometheus/client_python#1177 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
prometheus/client_python#1210 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 58/100
prometheus/client_python#1199 · リアクション 1 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
prometheus/client_python#1176 ·
-
難易度 1/5 1〜3時間 初心者へのやさしさ 52/100
prometheus/client_python#1126 · コメント 2 件 ·
prometheus/client_python の issue をすべて見る
似ている issue
-
agent-ready documentation needs-triage
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
-
documentation
難易度 1/5 1時間未満 初心者へのやさしさ 91/100
-
workflow-status page template still says reusable workflows are "triggered only by workflow_call:" オープン
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
-
instance instance add
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
searxng/searx-instances#939 · コメント 1 件 ·
-
area-deployment area-integrations triage:bot-seen
難易度 2/5 半日 初心者へのやさしさ 86/100