Skip to content

Commit 5aea509

Browse files
janlauberclaude
andcommitted
refactor(metrics): remove unused custom query builder
The QueryBuilder component (metric discovery, PromQL editor, label filtering) was not used in practice. Removes the frontend component, API functions, types, and corresponding backend handlers (/query, /discover, /labels) along with the MetricNames prometheus client method. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 841e67f commit 5aea509

10 files changed

Lines changed: 21 additions & 1093 deletions

File tree

extensions/metrics/backend/cmd/main.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ func main() {
5353
resourceHandler := handler.NewResource(promClient)
5454
appHandler := handler.NewApp(promClient)
5555
podsHandler := handler.NewPods(promClient)
56-
customHandler := handler.NewCustom(promClient)
57-
discoverHandler := handler.NewDiscover(promClient)
58-
labelsHandler := handler.NewLabels(promClient)
5956
perPodHandler := handler.NewPerPod(promClient)
6057

6158
// Config-driven dashboard handler
@@ -72,9 +69,6 @@ func main() {
7269
mux.HandleFunc("GET /api/v1/app-metrics", appHandler.Handle)
7370
mux.HandleFunc("GET /api/v1/pod-breakdown", podsHandler.Handle)
7471
mux.HandleFunc("GET /api/v1/per-pod-series", perPodHandler.Handle)
75-
mux.HandleFunc("GET /api/v1/query", customHandler.Handle)
76-
mux.HandleFunc("GET /api/v1/discover", discoverHandler.Handle)
77-
mux.HandleFunc("GET /api/v1/labels", labelsHandler.Handle)
7872
mux.HandleFunc("GET /healthz", func(w http.ResponseWriter, r *http.Request) {
7973
w.WriteHeader(http.StatusOK)
8074
})

extensions/metrics/backend/internal/handler/custom.go

Lines changed: 0 additions & 169 deletions
This file was deleted.

extensions/metrics/backend/internal/handler/dashboard.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,25 @@ func (h *Dashboard) HandleGraph(w http.ResponseWriter, r *http.Request) {
188188
json.NewEncoder(w).Encode(resp)
189189
}
190190

191+
// seriesLabel builds a human-readable label from metric labels.
192+
func seriesLabel(labels map[string]string) string {
193+
for _, key := range []string{"pod", "container", "namespace", "node", "instance"} {
194+
if v, ok := labels[key]; ok && v != "" {
195+
return fmt.Sprintf("%s=%s", key, v)
196+
}
197+
}
198+
var parts []string
199+
for k, v := range labels {
200+
if k != "__name__" {
201+
parts = append(parts, fmt.Sprintf("%s=%s", k, v))
202+
}
203+
}
204+
if len(parts) > 0 {
205+
return strings.Join(parts, ", ")
206+
}
207+
return "series"
208+
}
209+
191210
// renderTemplate executes a Go text/template with the given variables.
192211
func renderTemplate(expression string, vars map[string]string) (string, error) {
193212
tmpl, err := template.New("query").Parse(expression)

extensions/metrics/backend/internal/handler/discover.go

Lines changed: 0 additions & 113 deletions
This file was deleted.

0 commit comments

Comments
 (0)