fastapi-satella-metrics-2.0.0
توضیحات
A library for attaching Satella metrics to FastAPI
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | fastapi-satella-metrics-2.0.0 |
| نام | fastapi-satella-metrics |
| نسخه کتابخانه | 2.0.0 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Norbert Ozga |
| ایمیل نویسنده | norbert.ozga@dronehub.ai |
| آدرس صفحه اصلی | https://github.com/Dronehub/fastapi-satella-metrics |
| آدرس اینترنتی | https://pypi.org/project/fastapi-satella-metrics/ |
| مجوز | - |
fastapi-satella-metrics
=====================
[](https://travis-ci.com/Dronehub/fastapi-satella-metrics)
[](https://codeclimate.com/github/Dronehub/fastapi-satella-metrics/test_coverage)
[](https://codeclimate.com/github/Dronehub/fastapi-satella-metrics)
[](https://codeclimate.com/github/Dronehub/fastapi-satella-metrics)
[](https://pypi.python.org/pypi/fastapi-satella-metrics)
[](https://badge.fury.io/py/fastapi-satella-metrics)
[](https://pypi.python.org/pypi/fastapi-satella-metrics)
[](https://github.com/Dronehub/fastapi-satella-metrics)
fastapi-satella-metrics is an application to seamlessly measure your FastAPI
application using Satella's metrics.
Example use:
```python
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:
```python
app.add_middleware(SatellaMetricsMiddleware, exclude_metrics_endpoint=True)
```
Or to use your metrics:
```python
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:
```python
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:
```python
import fastapi
from fastapi_satella_metrics.prometheus_exporter import PrometheusExporter
app = fastapi.FastAPI()
app.include_router(PrometheusExporter({'service_name': 'my_service'}))
```
نیازمندی
| مقدار | نام |
|---|---|
| - | satella |
| - | fastapi |
| - | starlette |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| !=2.7.*,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.* | Python |
نحوه نصب
نصب پکیج whl fastapi-satella-metrics-2.0.0:
pip install fastapi-satella-metrics-2.0.0.whl
نصب پکیج tar.gz fastapi-satella-metrics-2.0.0:
pip install fastapi-satella-metrics-2.0.0.tar.gz