feat: add OpenTelemetry SDK, collector and telemetry stores

Collector (contrib), Prometheus, Loki, Tempo and Grafana with provisioning
from git; SDK in API and worker with level 3 metrics, traces and logs
carrying trace_id/span_id; telemetry off by default outside the stand;
broker healthcheck runs as the broker user so a fresh stand starts once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-11 10:19:50 +03:00
co-authored by Claude Opus 5.5
parent 9b35c256b7
commit a4497e3f32
62 changed files with 6175 additions and 214 deletions
+91
View File
@@ -0,0 +1,91 @@
# `driver.py stand-from-scratch --runs 2` (change `otel-telemetry`, задача 11.3)
- Основа: commit `9b35c25` (propose), **рабочее дерево не закоммичено** (apply change
`otel-telemetry`). Основная сессия решает, переснимать ли после коммита.
- Дата: 2026-11-11, старт 06:27:32Z, ~2 мин; команда из корня:
`python3 .claude/skills/run-mtusi-messenger/driver.py stand-from-scratch --runs 2`.
- Сценарий `container-run` «Стенд с нуля одной командой» (design, решения 19 и 21). Проект compose
`mtusi-lab6-scratch` (рабочий `mtusi-lab6` команда отказывается брать — код 2), свободные порты
хоста для `APP_OUT_PORT`, `POSTGRES_OUT_PORT`, `VALKEY_OUT_PORT`, `S3_OUT_PORT`,
`RABBITMQ_OUT_PORT`, `GRAFANA_OUT_PORT` аргументами `make run_docker`, `COMPOSE_PROJECT_NAME`
окружением. Перед первым прогоном и после каждого — `docker compose -p mtusi-lab6-scratch down -v
--remove-orphans` изнутри команды (в том числе при Ctrl+C): volumes проекта пусты перед прогоном и
после него. `.env` и `config.toml` — рабочего стенда (секреты те же, данные — свои volumes).
- Рабочий стенд на время проверки остановлен `make stop` (два стенда — 14 ГиБ лимитов на ВМ
7,75 ГиБ); его 17 контейнеров до и после — с теми же ID, затем `docker compose start`.
- До change на пустом volume брокер падал на `eacces` (`.erlang.cookie` от root,
`KNOWN_ISSUES.md`) и `make run_docker` кончался кодом 1; healthcheck теперь
`gosu rabbitmq rabbitmq-diagnostics -q check_port_connectivity`.
```
working stand mtusi-lab6: 17 containers
down -v mtusi-lab6-scratch: code 0
run 1: make run_docker took 13 s
down -v mtusi-lab6-scratch: code 0
run 2: make run_docker took 12 s
down -v mtusi-lab6-scratch: code 0
run 1: project volumes before expected 0 got 0
run 1: make run_docker exit code expected 0 got 0
run 1: api state expected running:0 got running:0
run 1: cleaner state expected running:0 got running:0
run 1: grafana state expected running:0 got running:0
run 1: haproxy state expected running:0 got running:0
run 1: loki state expected running:0 got running:0
run 1: migrate state expected exited:0 got exited:0
run 1: otel-collector state expected running:0 got running:0
run 1: postgres state expected running:0 got running:0
run 1: prometheus state expected running:0 got running:0
run 1: rabbitmq state expected running:0 got running:0
run 1: relay state expected running:0 got running:0
run 1: s3 state expected running:0 got running:0
run 1: s3-bootstrap state expected exited:0 got exited:0
run 1: tempo state expected running:0 got running:0
run 1: valkey state expected running:0 got running:0
run 1: worker state expected running:0 got running:0
run 1: rabbitmq RestartCount expected 0 got 0
run 1: otel-collector RestartCount expected 0 got 0
run 1: prometheus RestartCount expected 0 got 0
run 1: loki RestartCount expected 0 got 0
run 1: tempo RestartCount expected 0 got 0
run 1: grafana RestartCount expected 0 got 0
run 1: eacces / permission denied in logs expected 0 got 0
run 1: grafana datasources provisioned and healthy expected yes got yes
run 1: dashboard provisioned expected 200 True got 200 True
run 1: make test through its LB expected 0 PASS got 0 PASS
run 1: volumes left expected 0 got 0
run 2: project volumes before expected 0 got 0
run 2: make run_docker exit code expected 0 got 0
run 2: api state expected running:0 got running:0
run 2: cleaner state expected running:0 got running:0
run 2: grafana state expected running:0 got running:0
run 2: haproxy state expected running:0 got running:0
run 2: loki state expected running:0 got running:0
run 2: migrate state expected exited:0 got exited:0
run 2: otel-collector state expected running:0 got running:0
run 2: postgres state expected running:0 got running:0
run 2: prometheus state expected running:0 got running:0
run 2: rabbitmq state expected running:0 got running:0
run 2: relay state expected running:0 got running:0
run 2: s3 state expected running:0 got running:0
run 2: s3-bootstrap state expected exited:0 got exited:0
run 2: tempo state expected running:0 got running:0
run 2: valkey state expected running:0 got running:0
run 2: worker state expected running:0 got running:0
run 2: rabbitmq RestartCount expected 0 got 0
run 2: otel-collector RestartCount expected 0 got 0
run 2: prometheus RestartCount expected 0 got 0
run 2: loki RestartCount expected 0 got 0
run 2: tempo RestartCount expected 0 got 0
run 2: grafana RestartCount expected 0 got 0
run 2: eacces / permission denied in logs expected 0 got 0
run 2: grafana datasources provisioned and healthy expected yes got yes
run 2: dashboard provisioned expected 200 True got 200 True
run 2: make test through its LB expected 0 PASS got 0 PASS
run 2: volumes left expected 0 got 0
working stand mtusi-lab6: same container IDs expected yes got yes
PASS: make run_docker on empty volumes passed 2 times at the first attempt
```
Код выхода — 0. «running:0» — состояние и код выхода контейнера (`docker compose ps --format
json`) через 30 с после `make run_docker`; у двух реплик API состояние одно.