fastapi-satella-metrics
fastapi-satella-metrics is an application to seamlessly measure your FastAPI application using Satella's metrics.
Example use:
import fastapi
from fastapi_satella_metrics import SatellaMetricsMiddleware
app = fastapi.FastAPI()
app.add_middleware(SatellaMetricsMiddleware)
If you want to exclude /metrics endpoint from being metricized:
app.add_middleware(SatellaMetricsMiddleware, exclude_metrics_endpoint=True)
Or to use your metrics:
summary_metric = getMetric(
"requests_summary", "summary", quantiles=[0.2, 0.5, 0.9, 0.95, 0.99]
)
histogram_metric = getMetric("requests_histogram", "histogram")
response_codes_metric = getMetric("requests_response_codes", "counter")
app.add_middleware(
SatellaMetricsMiddleware,
summary_metric=summary_metric,
histogram_metric=histogram_metric,
response_codes_metric=response_codes_metric,
)
To launch a Prometheus exporter use the following snippet:
from satella.instrumentation.metrics.exporters import PrometheusHTTPExporterThread
phet = PrometheusHTTPExporterThread('0.0.0.0', 8080, {'service_name': 'my_service'})
phet.start()
Or, if you desire to export your metrics within FastAPI, just use:
import fastapi
from fastapi_satella_metrics.prometheus_exporter import PrometheusExporter
app = fastapi.FastAPI()
app.include_router(PrometheusExporter({'service_name': 'my_service'}))
Release files for fastapi-satella-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 | |
|---|---|---|---|
| fastapi-satella-metrics-2.0.0.tar.gz | 4.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fastapi_satella_metrics-2.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.0 kB
Release files / fastapi-satella-metrics-2.0.0.tar.gz
| Download URL | fastapi-satella-metrics-2.0.0.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5539dea4108840986559155e5a00e499550a51cf1f563d11962f2d7665e640fc
|
|
BLAKE2b-256 checksum How to use checksums |
2475337c13c6ea3f9a18212bd5a04764fcb63acdf037fc0924072010e748f458
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.8.0
|
Release files / fastapi_satella_metrics-2.0.0-py3-none-any.whl
| Download URL | fastapi_satella_metrics-2.0.0-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
28afbe915d878f3c8bf53b2a8f986fcae09bfe1e88a8a7c3c13094012063e56b
|
|
BLAKE2b-256 checksum How to use checksums |
8d9098b9a6dd9df3e3f74f090f06bb42bf4b77ac54ca646281539e32aea20173
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.8.0
|