feat: telemetry cost profile with head sampling, coarse buckets and balanced tail sampling

- [telemetry] trace_sample_ratio (ParentBased(TraceIdRatioBased), 1 keeps
  ParentBased(ALWAYS_ON)) and metric_buckets (default|coarse with SLO bounds),
  export interval <= 30 s; otel.sdk.span.started, span.live dropped; startup
  records name ratio, buckets and interval
- bench: telemetry services on mtusi-bench, TELEMETRY=on switch for uploads
  and queue, make bench_telemetry[_quick] with off/full/full-aa/head/tail/
  metrics/balanced, rare events, lookup from Tempo/Loki/Prometheus, cost
  sampler, verdicts H1-H8 and B1-B5; collector layers and lean Prometheus in
  bench/otel with preflight checks
- REPORT: telemetry cost hypotheses and criteria before the label

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-14 19:17:25 +03:00
co-authored by Claude Opus 5.5
parent 37f86801d6
commit 509afca89e
43 changed files with 5784 additions and 159 deletions
+50
View File
@@ -33,6 +33,9 @@ ROLES = (
"cleaner",
"haproxy",
)
# сервисы телеметрии стенда при выключателе TELEMETRY=on (design change
# track1-telemetry-cost, решение 13)
TELEMETRY_ROLES = ("otel-collector", "prometheus", "loki", "tempo")
# условие H6, записанное до метки: состав не меняется
H6_FLAGS = ("lost", "stuck", "duplicate", "sha_mismatch")
# пометки, при которых метка не зелёная: система потеряла работу (решение 11) или
@@ -177,6 +180,14 @@ CELL_FIELDS = [
"worker_exit_codes",
"worker_oom_events",
"lb_up_min",
# выключатель телеметрии (design change track1-telemetry-cost, решение
# 13): CPU и троттлинг окна over и пик памяти сервисов телеметрии; без
# телеметрии — пусто
*[
f"tel_{role.replace('-', '_')}_{key}"
for role in TELEMETRY_ROLES
for key in ("cpu_over", "throttle_over", "peak_mib")
],
]
TIMELINE_FIELDS = [
"cell",
@@ -983,6 +994,20 @@ def cell_row(cell: Mapping[str, Any], src: Sources) -> dict[str, Any]:
sum(1 for i in both_ready if done_at(i) > recovery_end),
)
row.update(control_columns(src.control, bounds))
for role in TELEMETRY_ROLES:
lives = src.cg.get(role, [])
prefix = f"tel_{role.replace('-', '_')}"
flat = [life for each in lives for life in each]
peaks = [p[1] for each in src.mp.get(role, []) for p in each]
row[f"{prefix}_cpu_over"] = (
role_cores(lives, over_start, over_end) if lives else None
)
row[f"{prefix}_throttle_over"] = (
throttle_share(flat, over_start, over_end) if flat else None
)
row[f"{prefix}_peak_mib"] = (
round(max(peaks) / 2**20, 1) if peaks else None
)
row["flags"] = " ".join(
cell_flags(row, zero_at is None, src.storage_down),
)
@@ -1854,6 +1879,29 @@ def block_table(rows: list[Mapping[str, Any]]) -> list[str]:
return lines
def telemetry_line(meta: Mapping[str, Any]) -> str:
"""Режим телеметрии метки (design change `track1-telemetry-cost`, решение
13) и предупреждение о сумме лимитов CPU больше ВМ."""
mode = meta.get("profile", {}).get("telemetry") or "off"
if mode != "on":
return (
"Телеметрия стенда выключена (TELEMETRY=off): SDK реплик, worker и "
"relay выключен, сервисов телеметрии нет."
)
budget = meta.get("resources", {}).get("budget", {})
text = (
"Телеметрия стенда включена (TELEMETRY=on): SDK реплик, worker и relay "
"с настройками рабочего стенда, Collector, Prometheus, Loki и Tempo "
"рабочего стенда; столбцы `tel_*` в конце `cells.csv`."
)
if budget.get("cpus", 0) > budget.get("vm_cpus", 0) > 0:
text += (
f" Сумма лимитов CPU {budget['cpus']:g} больше CPU ВМ "
f"{budget['vm_cpus']}: лимиты делят время, а не резервируют ядра."
)
return text
def render_summary(
meta: Mapping[str, Any],
rows: list[Mapping[str, Any]],
@@ -1868,6 +1916,8 @@ def render_summary(
f"dirty {meta.get('git', {}).get('dirty')}, статус "
f"{meta.get('status')}, ячеек {len(rows)} из {plan_total}.",
"",
telemetry_line(meta),
"",
]
fatal = [
f"`{row['cell']}`: {row['flags']}"