From ffe07ddef06429a0eb7b3da517be64c68c862c98 Mon Sep 17 00:00:00 2001 From: asepharyana Date: Wed, 22 Jul 2026 18:46:16 +0700 Subject: [PATCH] fix(infra): filter hub services by compose project label, fix TraceList field name collision --- infra/dashboard/main.go | 48 ++++++++++++++++++++--------------- infra/dashboard/template.html | 6 ++--- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/infra/dashboard/main.go b/infra/dashboard/main.go index f902f42..e4b6331 100644 --- a/infra/dashboard/main.go +++ b/infra/dashboard/main.go @@ -52,25 +52,26 @@ type Trace struct { } type DashboardData struct { - Services []Service - Running int - Down int - OTelOnly int - TraceCount int - RPS []float64 - Latency []float64 - Errors []float64 - Traces []float64 - Labels []string - HealthSVG template.HTML - RPSSVG template.HTML - LatencySVG template.HTML - ErrorSVG template.HTML - TraceSVG template.HTML - SystemName string - Error string - TotalUp int - TotalDown int + Services []Service + Running int + Down int + OTelOnly int + TraceCount int + RPS []float64 + Latency []float64 + Errors []float64 + TraceVolume []float64 + TraceList []Trace + Labels []string + HealthSVG template.HTML + RPSSVG template.HTML + LatencySVG template.HTML + ErrorSVG template.HTML + TraceSVG template.HTML + SystemName string + Error string + TotalUp int + TotalDown int } // ── State ── @@ -125,6 +126,7 @@ func fetchServices() []Service { var raw []struct { Names []string `json:"Names"` State string `json:"State"` + Labels map[string]string `json:"Labels"` NetworkSettings *struct { Networks map[string]any `json:"Networks"` } `json:"NetworkSettings"` @@ -136,7 +138,10 @@ func fetchServices() []Service { for _, c := range raw { if c.NetworkSettings != nil { if _, ok := c.NetworkSettings.Networks["app-shared-net"]; ok { - svcs = append(svcs, Service{Name: strings.TrimPrefix(c.Names[0], "/"), State: c.State}) + // Only include containers from the hub compose project + if c.Labels["com.docker.compose.project"] == "compose" { + svcs = append(svcs, Service{Name: strings.TrimPrefix(c.Names[0], "/"), State: c.State}) + } } } } @@ -456,7 +461,8 @@ func dashboard(w http.ResponseWriter, _ *http.Request) { data := DashboardData{ Services: svcs, Running: running, Down: down, OTelOnly: otel, - TraceCount: len(tr), RPS: rps, Latency: lat, Errors: ers, Traces: trc, Labels: labels, + TraceCount: len(tr), RPS: rps, Latency: lat, Errors: ers, + TraceVolume: trc, TraceList: tr, Labels: labels, SystemName: "asepharyana-hub", TotalUp: running, TotalDown: down + otel, HealthSVG: template.HTML(svgDonut(running, down, otel)), RPSSVG: template.HTML(svgLine(rps, "#58a6ff")), diff --git a/infra/dashboard/template.html b/infra/dashboard/template.html index 2998d41..e5e617a 100644 --- a/infra/dashboard/template.html +++ b/infra/dashboard/template.html @@ -120,7 +120,7 @@
{{len .Services}}
Total
{{.Running}}
Healthy
-
{{if .Traces}}{{printf "%.0f" (index .Traces (sub (len .Traces) 1))}}{{else}}0{{end}}
Traces
+
{{if .TraceVolume}}{{printf "%.0f" (index .TraceVolume (sub (len .TraceVolume) 1))}}{{else}}0{{end}}
Traces
{{if .Errors}}{{printf "%.0f" (index .Errors (sub (len .Errors) 1))}}{{else}}0{{end}}
Errors
@@ -175,9 +175,9 @@

Recent Traces

{{.TraceCount}}
- {{if .Traces}} + {{if .TraceList}}
- {{range .Traces}} + {{range .TraceList}}
{{.Service}}