Django Prometheus business metrics
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.
Usage
-
Create a
BusinessMetricsManagerobject 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-metricsendpoint.
Development
Pre-requisites:
- uv
- nox - may be installed as
uv tool install --with pyyaml --exclude-newer "14 days" nox - docker and docker compose plugin
Ideally, you should run nox -s 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 -s format lint test`
If you wish to install dependencies into .venv so your IDE can pick them up, you can do so using:
uv sync --all-extras --dev
Python / django version compatibility
Use cruft questionnaire to add/remove supported versions: cruft update --cookiecutter-input
Versioning
This package uses Semantic Versioning and Conventional Commits.
Commitizen may be used to generate commit messages:
uv tool install "commitizen==4.13.9"
git add ...
cz commit
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.
Release process
Releases are prepared explicitly by developers with help of Commitizen. Run cz bump which will:
- update the changelog
- make the bump commit and tag it
Then push the commit & tag to the repository, which will trigger the release workflow:
git push origin HEAD --follow-tags
alpha,betaandrcreleases are published to TestPyPI (usecz bump --prerelease alpha|beta|rcto create them)- regular ones are published to PyPI
Metadata
Release files for django-business-metrics 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django_business_metrics-2.0.0.tar.gz | 41.8 kB | With provenance | Details for django_business_metrics-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_business_metrics-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for django_business_metrics-2.0.0-py3-none-any.whl |
Total release size: 48.6 kB
Release files / django_business_metrics-2.0.0.tar.gz
| Download URL | django_business_metrics-2.0.0.tar.gz |
|---|---|
| Size | 41.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fd11e88d19b85053df992205a1362cdd3156e0eb9ebdb68e54fb1a963ac71cee
|
|
BLAKE2b-256 checksum How to use checksums |
e5992a75aa3c3d30791b60c0360c6d71d985baaeb56d810a39bd5d64f855c8b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.
Transparency logRelease files / django_business_metrics-2.0.0-py3-none-any.whl
| Download URL | django_business_metrics-2.0.0-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b9a9a5f5e7a20d09a8e74df9b343bf8b36aea1d0f6db4d447554ded8ed10b9b3
|
|
BLAKE2b-256 checksum How to use checksums |
f41a14603b6cb1ebec5e2f1ea03704b703d8a34d6c1af6cbac0193964884af52
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.
Transparency logSecurity for django-business-metrics 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for django_business_metrics-2.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.