Skip to content

Commit ec0311d

Browse files
authored
Merge pull request #133 from vcon-dev/feature/queue-stats-endpoint
Add /stats/queue endpoint for Redis queue depth monitoring
2 parents a2fc92d + f8f67e7 commit ec0311d

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

server/api.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,24 @@ async def health_check() -> JSONResponse:
260260
})
261261

262262

263+
@app.get(
264+
"/stats/queue",
265+
summary="Get queue depth",
266+
description="Returns the number of items in a Redis list (queue)",
267+
tags=["system"],
268+
)
269+
async def get_queue_depth(
270+
list_name: str = Query(..., description="Name of the Redis list to measure")
271+
) -> JSONResponse:
272+
"""Get the current depth of a Redis list. Public endpoint (no auth) for monitoring and backpressure."""
273+
try:
274+
depth = await redis_async.llen(list_name)
275+
return JSONResponse(content={"list_name": list_name, "depth": depth})
276+
except Exception as e:
277+
logger.error(f"Error getting queue depth for '{list_name}': {str(e)}")
278+
raise HTTPException(status_code=500, detail="Failed to get queue depth")
279+
280+
263281
class Vcon(BaseModel):
264282
"""Pydantic model representing a vCon (Voice Conversation) record.
265283

0 commit comments

Comments
 (0)