Flake8 plugin for prometheus metric name validation
Project description
Flake8 prometheus metric name plugin
Flake8 plugin to check metrics name prefix for official client https://github.com/prometheus/client_python.
Installation
pip install flake8-prometheus-metrics-name
Usage
Imagine we have python module some_module.py
:
from prometheus_client import Counter
Counter(name='kek_values', documentation='some doc')
Counter(name='some_name1', documentation='some doc')
Counter(name='some_name2', documentation='some doc') # noqa: PRM902
Counter(name='some_name3', documentation='some doc')
Counter(name='lol_values', documentation='some doc')
Add valid metrics name prefixes to setup.cfg
:
[flake8]
prometheus-metrics-name-prefixes =
kek_
lol_
Run flake8 flake8 some_modue.py
cause following warnings:
some_module.py:4:1: PRM902: Metric name should start with one of following prefixes: "kek_", "lol_", got "some_name1" instead
some_module.py:6:1: PRM902: Metric name should start with one of following prefixes: "kek_", "lol_", got "some_name3" instead
Plugin also may be disabled by adding following option to setup.cfg
:
[flake8]
prometheus-metrics-disabled = 1
then AST nodes will not be analized for metrics name on flake8 run.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for flake8-prometheus-metrics-name-0.1.9.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3313e53fee57bc3d5ecc70aebf4f2fae0ae5ddf134dc0401eae6d01739d8b24 |
|
MD5 | 3730895190cf90c911d09d7e460478ed |
|
BLAKE2b-256 | 34a1e161cc21d4b800daf1ddaf9de97945dd21f136236648e56d9e87cea82939 |
Close
Hashes for flake8_prometheus_metrics_name-0.1.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a24405b4bcc3d7ff18c201d12b06bcbdb114587d673bebb55ed2b457d760d0e4 |
|
MD5 | 1ce8beaaae6e7e4edb8bc09d2e26877c |
|
BLAKE2b-256 | f8246ea00c5d42f5d392aea57fc0690d9b0c78701335d5c358f3cd7cc1c581ff |