feat(metrics): prometheus-метрики и сервер /metrics

- src/metrics.py: счётчики строк, чанков, файлов (processed/failed) и start_metrics_server
- settings: METRICS_ENABLED (true), METRICS_PORT (9100)
- main: запуск сервера метрик перед pipeline
- pipeline: учёт записанных в Qdrant строк/чанков; финальная группа
  без чанков сдвигает чекпоинт, не вызывая embed/upsert
- helm: порт metrics в контейнере, METRICS_ENABLED/METRICS_PORT в configmap
- prometheus-client в зависимостях, тесты и документация
This commit is contained in:
mike committed 2026-11-24 17:03:06 +03:00
1 parent 6b4d791ff5
commit 516242f3de
14 files changed
+289 -11

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
"""Тесты Prometheus-метрик сервиса (src/metrics.py)."""
from __future__ import annotations
from src import metrics
def test_start_metrics_server_uses_given_port(mocker) -> None:
"""start_metrics_server передаёт порт в prometheus_client.start_http_server."""
start_mock = mocker.patch("src.metrics.start_http_server")
metrics.start_metrics_server(9100)
start_mock.assert_called_once_with(9100)
def test_metric_names_exposed_in_registry() -> None:
"""Счётчики зарегистрированы с ожидаемыми именами (с суффиксом _total)."""
from prometheus_client import REGISTRY
names = {
sample.name
for metric in REGISTRY.collect()
for sample in metric.samples
}
for name in (
"etl_rows_processed_total",
"etl_chunks_upserted_total",
"etl_files_processed_total",
"etl_files_failed_total",
):
assert name in names