This Django app provides a Prometheus metrics endpoint serving so-called business metrics. These are metrics that are calculated when Prometheus hits the metrics endpoint.
Important
This package uses ApiVer, make sure to import django_business_metrics.v0
.
-
Create a
BusinessMetricsManager
object and register some metrics:# project/business_metrics.py from django_business_metrics.v0 import BusinessMetricsManager, users metrics_manager = BusinessMetricsManager() # Add a pre-defined metric metrics_manager.add(users) # Add some custom metrics @metrics_manager.metric(name='name', documentation='documentation') def my_metric(): return 10
-
Register a Prometheus endpoint:
# project/urls.py ... from .business_metrics import metrics_manager ... urlpatterns = [ ... path('business-metrics', metrics_manager.view), ... ]
-
Setup your Prometheus agent to scrape metrics from
/business-metrics
endpoint.
This package uses Semantic Versioning.
TL;DR you are safe to use compatible release version specifier ~=MAJOR.MINOR
in your pyproject.toml
or requirements.txt
.
Additionally, this package uses ApiVer to further reduce the risk of breaking changes.
This means, the public API of this package is explicitly versioned, e.g. django_business_metrics.v1
, and will not change in a backwards-incompatible way even when django_business_metrics.v2
is released.
Internal packages, i.e. prefixed by django_business_metrics._
do not share these guarantees and may change in a backwards-incompatible way at any time even in patch releases.
Pre-requisites:
Ideally, you should run nox -t format lint
before every commit to ensure that the code is properly formatted and linted.
Before submitting a PR, make sure that tests pass as well, you can do so using:
nox -t check # equivalent to `nox -t format lint test`
If you wish to install dependencies into .venv
so your IDE can pick them up, you can do so using:
pdm install --dev
Run nox -s make_release -- X.Y.Z
where X.Y.Z
is the version you're releasing and follow the printed instructions.