v0.1.2
Go quality gates / test (push) Waiting to run

This commit is contained in:
Mateusz Gruszczyński committed 2026-12-01 00:16:15 +01:00
1 parent de13d851a8
commit a28362b82c
34 files changed
+1541 -341

No files matched your search

+10 -2
View File
@@ -124,7 +124,8 @@ func saturatingAdd(a, b uint64) uint64 {
// fleetTelemetry is a panel-internal authenticated JSON endpoint. It never
// calls a non-existent EasyDNS endpoint; all data comes from sampled /stats.
func (s *Server) fleetTelemetry(w http.ResponseWriter, _ *http.Request, mode string) {
func (s *Server) fleetTelemetry(w http.ResponseWriter, r *http.Request, mode string) {
window := telemetry.ParseWindow(r.URL.Query().Get("range"), r.URL.Query().Get("step"), time.Now().UTC())
all := s.nodes.All()
nodes := make([]telemetry.FleetNode, 0, len(all))
for _, n := range all {
@@ -144,11 +145,18 @@ func (s *Server) fleetTelemetry(w http.ResponseWriter, _ *http.Request, mode str
response := map[string]any{
"mode": mode, "nodes": nodes, "total": len(all),
"intervalSeconds": 15,
"range": window.Range, "step": window.Step, "stepSeconds": window.StepSeconds,
"from": window.From, "to": window.To, "retentionHours": 24,
}
if mode == "aggregate" {
response["samples"] = telemetry.AggregateFleet(nodes)
// Aggregate raw aligned samples first; independently downsampling each
// node would destroy time alignment and bias fleet values.
response["samples"] = telemetry.WindowFleet(telemetry.AggregateFleet(nodes), window)
response["aggregation"] = "strict-complete: rates sum only when every server has a fresh sample; cache ratio weighted by cache lookups; latency per node"
}
for i := range nodes {
nodes[i].Samples = telemetry.WindowSamples(nodes[i].Samples, window)
}
w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.Header().Set("Cache-Control", "no-store")
_ = json.NewEncoder(w).Encode(response)