feat: add SLOs, Prometheus alert rules and telemetry loss accounting

HAProxy /metrics scraped by the Collector, recording rules and seven alerts with promtool tests and runbooks (make alerts_test, CI step), byte-sized Collector export queues with 30 s retries, SDK internal metrics, SLO/LB/pipeline dashboard rows, driver commands alerts-check and backend-outage (change slo-alerts).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-12 00:35:01 +03:00
co-authored by Claude Opus 5.5
parent 839433c23b
commit 15ea156404
33 changed files with 4764 additions and 176 deletions
+31
View File
@@ -494,6 +494,37 @@ bench_ab:
$(KEEP_AWAKE) uv run python bench/ab.py --before "$(BEFORE)" --after "$(AFTER)" --reapply "$(REAPPLY)" $(if $(SERIES),--series "$(SERIES)")
# -------------------------
# Observability
# -------------------------
PROMETHEUS_DIR = infra/otel/prometheus
# правила Prometheus без стенда и без сети (design change slo-alerts, решение
# 11): файлы infra/otel/prometheus/ — tar в одноразовый контейнер
# закреплённого образа Prometheus (образ — из docker-compose.yml), там promtool
# check config, check rules и test rules; затем у каждого оповещения есть
# runbook_url, и каждый названный runbook — файл в git. Через stdin, а не bind
# mount: так же работает в CI (job не видит своих файлов на хосте Docker)
.PHONY: alerts_test
alerts_test:
@image=$$(sed -n 's/^ *image: *\(prom\/prometheus:[^ ]*\).*$$/\1/p' docker-compose.yml | head -n 1); \
if [ -z "$$image" ]; then echo "prometheus image is not found in docker-compose.yml"; exit 2; fi; \
echo "promtool from $$image"; \
tar -C $(PROMETHEUS_DIR) -cf - prometheus.yml rules.yml rules.test.yml | \
docker run --rm -i --network none --entrypoint sh "$$image" -c \
'set -e; cd /etc/prometheus; tar -xf -; promtool check config prometheus.yml; promtool check rules rules.yml; promtool test rules rules.test.yml'
@alerts=$$(grep -c '^ *- alert:' $(PROMETHEUS_DIR)/rules.yml); \
urls=$$(grep -c '^ *runbook_url:' $(PROMETHEUS_DIR)/rules.yml); \
if [ "$$alerts" -ne "$$urls" ]; then echo "alerts: $$alerts, runbook_url: $$urls"; exit 1; fi; \
missing=0; \
for path in $$(sed -n 's/^ *runbook_url: *//p' $(PROMETHEUS_DIR)/rules.yml); do \
if [ -f "$$path" ]; then echo "runbook $$path: ok"; else echo "runbook $$path: MISSING"; missing=1; fi; \
done; \
if [ "$$missing" -ne 0 ]; then exit 1; fi; \
echo "alerts: $$alerts, each with an existing runbook"
# -------------------------
# Common targets
# -------------------------