feat: Add FastAPI s6 sidecar PoC
- Sidecar DragonflyDB as Redis replacement - Run pytheus in multiprocessing mode with Redis backend
This commit is contained in:
20
app/main.py
Normal file
20
app/main.py
Normal file
@ -0,0 +1,20 @@
|
||||
from fastapi import FastAPI
|
||||
from fastapi.responses import PlainTextResponse
|
||||
from pytheus.exposition import generate_metrics
|
||||
from pytheus.middleware import PytheusMiddlewareASGI
|
||||
|
||||
from pytheus.backends import load_backend
|
||||
from pytheus.backends.redis import MultiProcessRedisBackend
|
||||
|
||||
load_backend(
|
||||
backend_class=MultiProcessRedisBackend,
|
||||
backend_config={"host": "127.0.0.1", "port": 6379},
|
||||
)
|
||||
|
||||
app = FastAPI()
|
||||
app.add_middleware(PytheusMiddlewareASGI)
|
||||
|
||||
|
||||
@app.get("/metrics", response_class=PlainTextResponse)
|
||||
async def pytheus_metrics():
|
||||
return generate_metrics()
|
||||
Reference in New Issue
Block a user