支持ASGI应用程序的Prometheus指标
项目描述
asgi-prometheus – 支持ASGI应用程序的Prometheus指标(《Asyncio》/Trio,/Curio)
需求
python >= 3.9
安装
应使用pip安装asgi-prometheus
pip install asgi-prometheus
使用
常见ASGI应用程序
from asgi_prometheus import PrometheusMiddleware
async def my_app(scope, receive, send):
"""Read session and get the current user data from it or from request query."""
await send({"type": "http.response.start", "status": status, "headers": headers})
await send({"type": "http.response.body", "body": b"Hello World!"})
app = PrometheusMiddleware(my_app, metrics_url="/metrics", group_paths=['/'])
# http GET / -> OK
# http GET /metrics -> [Prometheus metrics]
作为ASGI-Tools内部中间件
from asgi_tools import App
from asgi_prometheus import PrometheusMiddleware
app = App()
app.middleware(PrometheusMiddleware.setup(group_paths=['/views', '/api']))
@app.route('/')
async def index(request):
return 'Hello World!'
# http GET / -> OK
# http GET /prometheus -> [Prometheus metrics (default URL)]
选项
from asgi_sessions import PrometheusMiddleware
app = PrometheusMiddleware(
# Your ASGI application
app,
# Metrics URL for Prometheus (set empty string to disable)
metrics_url='/prometheus',
# List of path's prefixes to group. A path which starts from the prefix will be grouped.
# For example: group_paths=['/api/users'], "/api/users/1", "/api/users/2" will be grouped into "/api/users*"
group_paths=[],
)
错误跟踪器
如果您有任何建议、错误报告或不满,请向https://github.com/klen/asgi-prometheus/issues的issue tracker报告
贡献
许可证
在MIT许可证下发布。
项目详情
关闭
asgi_prometheus-1.2.3.tar.gz的散列值
算法 | 散列摘要 | |
---|---|---|
SHA256 | 8e047959ff1cef1b1bad9ddce46723a8f030ad7e7b98bb3d58e1b1619ad166b8 |
|
MD5 | 7094cb5982c524caeb8029cad3e2c5c3 |
|
BLAKE2b-256 | 7ef059eeda10f472c450969042b952ce3b6f390ef41d683b7986d909237f2b16 |
关闭
asgi_prometheus-1.2.3-py3-none-any.whl的散列值
算法 | 散列摘要 | |
---|---|---|
SHA256 | c37e0d8dbd7561fd169511d4f0fde0c040d4e89e58ee4889a29fcf4bff0fef78 |
|
MD5 | 9234b242fe5a3197db2d023f4e0514a1 |
|
BLAKE2b-256 | 016c43a1a98f014e9aab28bf3a1bd77d5182df12cd057131486352bde0013ec4 |