Skip to main content

Flake8 plugin for prometheus metric name validation

Project description

Flake8 prometheus metric name plugin

pypi Python: 3.6+ License: MIT Code style: black

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flake8_prometheus_metrics_name-0.1.14.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file flake8_prometheus_metrics_name-0.1.14.tar.gz.

File metadata

File hashes

Hashes for flake8_prometheus_metrics_name-0.1.14.tar.gz
Algorithm Hash digest
SHA256 9e54c67ca82858160835017a7a84c67600a81fde905af4d37918284907e357b6
MD5 461d3e71f274e633467009b8dc8f1995
BLAKE2b-256 1a359c10422bbffabe518d5cbfad5a3befba3f136179836129f9f19fb5840696

See more details on using hashes here.

File details

Details for the file flake8_prometheus_metrics_name-0.1.14-py3-none-any.whl.

File metadata

File hashes

Hashes for flake8_prometheus_metrics_name-0.1.14-py3-none-any.whl
Algorithm Hash digest
SHA256 ef36b28e7dcf9bc22c07b0c40590c7067944d999c505723aeabc745f9426253b
MD5 f908c3775b008a4f1712c6bbb398747e
BLAKE2b-256 2fb30ba525cf94ee8fe6f6e114d9dfe26a45d1337936dad54d0e7eb5f0ae72ca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page