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
```bash
pip install flake8-prometheus-metrics-name
```
## Usage
Imagine we have python module `some_module.py`:
```python
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`:
```buildoutcfg
[flake8]
prometheus-metrics-name-prefixes =
kek_
lol_
```
Run flake8 `flake8 some_modue.py` cause following warnings:
```bash
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`:
```buildoutcfg
[flake8]
prometheus-metrics-disabled = 1
```
then AST-tree nodes will not be analized for metrics name on flake8 run.
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.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f53ef4b0b85a16977165a9c36de96f9ccfc0e7ab26b52ffa8cfe7764ad0c4d56 |
|
MD5 | 97f98f2d69b9dc17754d77103ffcb08c |
|
BLAKE2b-256 | a2dff5b91e692bf08071b463750f14f0249977568f27f5fa37ed9217447eb31c |
Close
Hashes for flake8_prometheus_metrics_name-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3780f70176d2565841a06b9a6b1da1b1fc48e83e0fab674dc955808fca44005 |
|
MD5 | 0d5dca30f0efc766951aa8630eeb3e0e |
|
BLAKE2b-256 | 2576bed8cd3b330a79a80f481450827da6c31d0074e53a679e17450190aab984 |