forked from mtusi2026/mtusi2026lab6
ЛР6: OpenTelemetry, Collector, Prometheus/Loki/Tempo, Grafana, алерты, исследование цены наблюдаемости
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python3
|
||||
"""График трека 1 из evidence/obs_cost.json: python research/plot_obs_cost.py --out evidence"""
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
|
||||
import matplotlib
|
||||
|
||||
matplotlib.use("Agg")
|
||||
import matplotlib.pyplot as plt # noqa: E402
|
||||
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--out", default="evidence")
|
||||
out = ap.parse_args().out
|
||||
d = json.load(open(os.path.join(out, "obs_cost.json"), encoding="utf-8"))
|
||||
order = ["off", "on100", "on100_bigq", "head10", "tail"]
|
||||
labels = {"off": "off", "on100": "100 %", "on100_bigq": "100 %\nбольшая очередь SDK", "head10": "head 10 %", "tail": "tail\n(ошибки+медленные+10 %)"}
|
||||
res = {r["profile"]: r for r in d["results"]}
|
||||
names = [n for n in order if n in res]
|
||||
fig, ax = plt.subplots(1, 4, figsize=(19, 4.8))
|
||||
ax[0].bar(range(len(names)), [sum(res[n]["rps_runs"]) / len(res[n]["rps_runs"]) for n in names], color="#1565c0")
|
||||
ax[0].set_title("Успешных запросов/с (среднее 2 прогонов)")
|
||||
ax[1].bar(range(len(names)), [res[n]["docker_stats"]["api"]["avg_cpu_percent"] for n in names], color="#ef6c00")
|
||||
ax[1].set_title("CPU API, % одного ядра (на реплику)")
|
||||
ax[2].bar([i - 0.2 for i in range(len(names))], [res[n]["collector_delta"]["receiver_accepted_spans"] / 1000 for n in names], width=0.4, label="спаны: SDK → Collector", color="#6a1b9a")
|
||||
ax[2].bar([i + 0.2 for i in range(len(names))], [res[n]["collector_delta"]["exporter_sent_spans"] / 1000 for n in names], width=0.4, label="спаны: Collector → Tempo", color="#2e7d32")
|
||||
ax[2].set_title("Спанов за окно 30 с + 25 с, тыс."); ax[2].legend()
|
||||
ax[3].bar([i - 0.2 for i in range(len(names))], [min(1.0, (res[n]["kept_ratio"]["errors"] or 0)) * 100 for n in names], width=0.4, label="ошибки (500)", color="#c62828")
|
||||
ax[3].bar([i + 0.2 for i in range(len(names))], [min(1.0, (res[n]["kept_ratio"]["slow"] or 0)) * 100 for n in names], width=0.4, label="медленные (>500 мс)", color="#00838f")
|
||||
ax[3].set_title("Доля сохранённых в Tempo трасс, %"); ax[3].legend()
|
||||
for a in ax:
|
||||
a.set_xticks(range(len(names)))
|
||||
a.set_xticklabels([labels[n] for n in names], fontsize=8)
|
||||
fig.tight_layout()
|
||||
fig.savefig(os.path.join(out, "obs_cost.png"), dpi=110)
|
||||
print("saved")
|
||||
Reference in New Issue
Block a user