← Back to Pull requests

feat(analytics): split kci-dev, scripts, and bots from dashboard traffic #2154

Closed
unknown closed this pull request without merging on Oct 07, 2026 17:54 UTC
View on GitHub
unknown unknown commented on Oct 01, 2026 19:26 UTC
Author

What it is

Classify User-Agents into client dashboard, kci-dev, script, or bot
Record kci-dev/<version> as the browser, and Linux, macOS, or Windows from (OS) in the User-Agent
Add a client label to request counts and daily unique visitors
Add a Client control on the Grafana API dashboard and filter the analytics panels with it
New client series start at deploy. Older samples without that label stay in Prometheus until they age out of the selected range.
Closes #2144

How to test

From backend/:

poetry run pytest -m unit kernelCI_app/tests/unitTests/middleware/backendRequestMetricsMiddleware_test.py -q

1. docker compose -f docker-compose.monitoring.yml up -d
2. Start the backend with PROMETHEUS_METRICS_ENABLED=true and metrics on port 8001. runserver needs --noreload.
3. Send a few /api/ requests:
curl -H 'User-Agent: kci-dev/0.1.11 (Linux)' http://localhost:8000/api/schema/
curl -H 'User-Agent: curl/8.5.0' http://localhost:8000/api/schema/
curl -H 'User-Agent: Mozilla/5.0 (compatible; Googlebot/2.1)' http://localhost:8000/api/schema/
curl -A 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 Chrome/131.0.0.0 Safari/537.36' http://localhost:8000/api/schema/

4. On http://localhost:8001/metrics/ confirm client="kci-dev", client="script", client="bot", and client="dashboard". The kci-dev request series should show browser="kci-dev/0.1.11", os="Linux",
device="cli".
5. In Grafana at http://localhost:3000, import monitoring/dashboard.json. Set the range to the last 15 minutes.
6. Client: All clients shows one unique-visitor total and one slice per client on Requests by Client. Client: kci-dev limits the analytics panels to that client. Response time and total calls
stay unchanged, because those series have no client label.

Diff: 231 lines (+173 / -58) across 2 files Reviewer: bhcopeland Review duration: 8547m
All Vouch review confidence checks passed
Residual risk 0.15 = Change Risk (0.37) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 231 lines diff across 2 files
0.37
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.326
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #2154"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 37% (MEDIUM) · Higher = larger blast radius
37%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 14.6% · Safe to merge
14.6%