Blacksheep Prometheus
Introduction
Prometheus integration for Blacksheep.
Requirements
- Python 3.7+
- Blacksheep 1.0.7+
Installation
$ pip install blacksheep-prometheus
Usage
A complete example that exposes prometheus metrics endpoint under default /metrics/ endpoint.
from blacksheep.server import Application
from blacksheep_prometheus import use_prometheus_metrics
app = Application()
use_prometheus_metrics(app)
Options
| Option name | Description | Default value |
|---|---|---|
requests_total_metric_name |
name of metric for total requests | 'backsheep_requests_total' |
responses_total_metric_name |
name of metric for total responses | 'backsheep_responses_total' |
request_time_seconds_metric_name |
name of metric for request timings | 'backsheep_request_time_seconds' |
exceptions_metric_name |
name of metric for exceptions | 'backsheep_exceptions' |
requests_in_progress_metric_name |
name of metric for in progress requests | 'backsheep_requests_in_progress' |
filter_paths |
list of path's where do not need to collect metrics | [] |
Custom metrics
blacksheep-prometheus will export all the prometheus metrics from the process, so custom metrics can be created by using the prometheus_client API.
Example:
from prometheus_client import Counter
from blacksheep.server.responses import redirect
REDIRECT_COUNT = Counter("redirect_total", "Count of redirects", ("from_view",))
async def some_view(request):
REDIRECT_COUNT.labels(from_view="some_view").inc()
return redirect("https://example.com")
The new metric will now be included in the the /metrics endpoint output:
...
redirect_total{from_view="some_view"} 2.0
...
Contributing
This project is absolutely open to contributions so if you have a nice idea, create an issue to let the community discuss it.
Metadata
Release files for blacksheep-prometheus 0.1.8
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 |
|---|---|---|---|---|
| blacksheep-prometheus-0.1.8.tar.gz | 4.6 kB | Without provenance | Details for blacksheep-prometheus-0.1.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| blacksheep_prometheus-0.1.8-py3-none-any.whl | Python 3 | none | any | Details for blacksheep_prometheus-0.1.8-py3-none-any.whl |
Total release size: 10.5 kB
Release files / blacksheep-prometheus-0.1.8.tar.gz
| Download URL | blacksheep-prometheus-0.1.8.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a0bbd318825f7036f6aa4e75056ecee89ada9fe5df5fc097911cc95ba9d9f291
|
|
BLAKE2b-256 checksum How to use checksums |
39033b1342cc4996ef64d8771484193f0500b8f1c377ccd344a7eed2b4b2709d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.8.13 Linux/5.13.0-1022-azure
|
Release files / blacksheep_prometheus-0.1.8-py3-none-any.whl
| Download URL | blacksheep_prometheus-0.1.8-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1bb7aa441cf8b8e966b5f72cb15a03a01c12732d9fe7e9547cb31036ccec3e0c
|
|
BLAKE2b-256 checksum How to use checksums |
58dcd700443026a792a021cbc3a1a748d3de08712d725f7819d941abfa760099
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.8.13 Linux/5.13.0-1022-azure
|
Security for blacksheep-prometheus 0.1.8
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.