prometheus / prometheus/client_python
Default namespace/prefix for all exported metrics?
オープン
まだ誰も着手していません。
feature
- 主要言語
- Python
- スター
- 4.4k
- フォーク
- 876
- 平均マージ
- 8日 4時間
- マージ済み PR(30日)
- 1
説明
Is there a way to define a default, global prefix for all metrics?
For example instead of:
python_gc_objects_collected_total
I'd like to add the prefix myproject_:
myproject_python_gc_objects_collected_total
I'm currently doing it like that:
_original_generate_latest = prometheus_client.openmetrics.exposition.generate_latest
def init_prometheus(namespace):
def new_generate_latest(*args, **kwargs):
original_output = _original_generate_latest(*args, **kwargs).decode('utf-8')
namespace_prefix = namespace + '_'
new_output = ''
for line in original_output.splitlines():
if not line.startswith('#') and not line.startswith(namespace_prefix):
new_output += namespace_prefix
new_output += line + '\n'
new_output = new_output.encode('utf-8')
return new_output
prometheus_client.generate_latest = new_generate_latest
But it doesn't always work. For example, prometheus_client.start_http_server ignores this function for whatever reason.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、issueで言及されている公開されたgenerate_latest関数とprometheus_client.start_http_serverエントリーポイントを追跡します。それぞれの経路でエクスポートされるメトリクスがどのように生成されるかを明らかにし、設定された1つのプレフィックスがすべてのエクスポートされるメトリクスに一貫して適用され、monkey-patchingを行わないことを完了条件とします。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- prometheus, python
- 領域
- observability
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100