feat: 31 new tests, metrics LLM counters, Dockerfile caching, Makefile targets, compose limits, code fixes

This commit is contained in:
Marker689
2026-05-11 23:08:09 +03:00
parent 20bf7e6745
commit 18efcf482e
26 changed files with 840 additions and 12 deletions

View File

@@ -33,6 +33,19 @@ async def metrics(session: AsyncSession = Depends(get_session)) -> Response:
# Latest scan timestamp
latest = await session.scalar(select(func.max(Scan.started_at)))
# LLM analysis
analyzed = (
await session.scalar(
select(func.count(Finding.id)).where(
func.json_extract(Finding.report, "$.verdict").isnot(None)
)
)
or 0
)
pending = (
await session.scalar(select(func.count(Finding.id)).where(Finding.report.is_(None))) or 0
)
lines = [
"# HELP guarddog_scans_total Total number of package scans.",
"# TYPE guarddog_scans_total counter",
@@ -46,6 +59,14 @@ async def metrics(session: AsyncSession = Depends(get_session)) -> Response:
"# TYPE guarddog_findings_total counter",
f"guarddog_findings_total {findings_total}",
"",
"# HELP guarddog_llm_analyzed_total Total findings analyzed by LLM.",
"# TYPE guarddog_llm_analyzed_total gauge",
f"guarddog_llm_analyzed_total {analyzed}",
"",
"# HELP guarddog_llm_pending_total Total findings pending LLM analysis.",
"# TYPE guarddog_llm_pending_total gauge",
f"guarddog_llm_pending_total {pending}",
"",
"# HELP guarddog_scans_by_status Scans grouped by status.",
"# TYPE guarddog_scans_by_status gauge",
]