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.7.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | cda0a4ea21dc7fa4b12f7b47f63a875b5fde809eac1e74cdd1a7f49660d351c8 |
|
MD5 | 438c232af4aa8205c169d22d566217f2 |
|
BLAKE2b-256 | 9204ce701655fb71c552f624689034ede1241f467d4595e8c18392ae4b80289c |
Close
Hashes for flake8_prometheus_metrics_name-0.1.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2723c08ee0f0fbcfcd8ee622dc5a6c3038683ab657c539211c423b7368ec0e73 |
|
MD5 | f8ed2a640e06ae2dc1812652ef4356f8 |
|
BLAKE2b-256 | faf776ff3c0207102c0a773d0dff6781910007b378f5f9a26b4a56ba4202f142 |