nameko-prometheus
docs |
|
|---|---|
tests |
|
package |
nameko-prometheus is a dependency for the nameko microservice framework which allows application metrics collection with Prometheus.
Features
automatic collection of request latency metrics for RPC methods, event handlers and HTTP requests
custom application metrics are also exposed automatically
HTTP endpoint exposing metrics to be scraped by Prometheus
Installation
pip install nameko-prometheus
You can also install the in-development version with:
pip install https://github.com/emplocity/nameko-prometheus/archive/master.zip
Usage
Define your application metrics using types from prometheus_client, such as Counter, Gauge, Histogram, etc. Add a PrometheusMetrics dependency provider to your service class. Then add a HTTP entrypoint (usually routed under /metrics URL) that forwards the request to expose_metrics() method of the provider. That’s it!
from nameko.rpc import rpc
from nameko.web.handlers import http
from nameko_prometheus import PrometheusMetrics
from prometheus_client import Counter
work_units = Counter(
"my_service_work_units_total", "Total number of work units", ["work_type"]
)
class MyService:
metrics = PrometheusMetrics()
@rpc
def say_hello(self):
work_units.labels(work_type="hard").inc()
return "Hello!"
@http("GET", "/metrics")
def serve_metrics(self, request):
return self.metrics.expose_metrics(request)
There are a few automatically defined metrics as well. See the documentation of PrometheusMetrics for more.
See also the full stack example in example/ directory in this repo.
Documentation
Development
To run the all tests run:
tox
Note, to combine the coverage data from all the tox environments run:
Windows |
set PYTEST_ADDOPTS=--cov-append tox |
|---|---|
Other |
PYTEST_ADDOPTS=--cov-append tox |
Development roadmap
Things we’d like to have in the future:
automatic registration of /metrics HTTP endpoint
decorator to exclude specific methods from tracing
License
This work is released under the Apache 2.0 license.
Metadata
Release files for nameko-prometheus 1.6.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 |
|---|---|---|---|---|
| nameko-prometheus-1.6.0.tar.gz | 19.7 kB | Without provenance | Details for nameko-prometheus-1.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nameko_prometheus-1.6.0-py3-none-any.whl | Python 3 | none | any | Details for nameko_prometheus-1.6.0-py3-none-any.whl |
Total release size: 27.8 kB
Release files / nameko-prometheus-1.6.0.tar.gz
| Download URL | nameko-prometheus-1.6.0.tar.gz |
|---|---|
| Size | 19.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a772885b9b21a9f684b36a36377ef0736944cc585d79db199b3c621cfb7d702a
|
|
BLAKE2b-256 checksum How to use checksums |
f8946c213a042ac1332a1ce7f8f82eda325eccef3212751a8b4fceddf402c9d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|
Release files / nameko_prometheus-1.6.0-py3-none-any.whl
| Download URL | nameko_prometheus-1.6.0-py3-none-any.whl |
|---|---|
| Size | 8.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
14dabded4763e25da5da60104396c0a0d02846f396a4adddfcdfff7425ff46e8
|
|
BLAKE2b-256 checksum How to use checksums |
8e0f75ba99e278c1f849a27a4cd0c67878bae64d710e2ee1e6fb5ec6c7ee0bfd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|
Security for nameko-prometheus 1.6.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.
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.