more
Build and Publish / Metadata (push) Successful in 3s
Build and Publish / BuildAndDeployAmd64 (push) Successful in 1m35s

This commit is contained in:
mats committed 2026-09-19 20:06:36 +02:00
1 parent 8f670dfa2f
commit 2237fbda55
15 files changed
+594 -52

No files matched your search

+35
View File
@@ -852,6 +852,41 @@ func (c *Collector) HandleStatsServices(w http.ResponseWriter, r *http.Request)
_ = json.NewEncoder(w).Encode(map[string]interface{}{"services": services})
}
// HandleStatsEndpoints returns normalized HTTP traffic groups. It is useful
// for diagnosing noisy hosts and proxy/instrumentation duplication without
// loading raw telemetry into the browser.
func (c *Collector) HandleStatsEndpoints(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
return
}
if !c.statsEnabled() {
statsNotEnabled(w)
return
}
service, hours := parseStatsCommon(r)
host := strings.ToLower(strings.TrimSpace(r.URL.Query().Get("host")))
limit := parseLimit(r, 100)
if limit <= 0 {
limit = 100
}
if limit > 500 {
limit = 500
}
stats, err := c.statsQuerier.EndpointStats(r.Context(), host, service, hours, limit)
if err != nil {
log.Printf("failed to compute endpoint stats: %v", err)
http.Error(w, "failed to compute endpoint stats", http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", "application/json")
_ = json.NewEncoder(w).Encode(map[string]interface{}{
"hours": hours,
"host": host,
"endpoints": stats,
})
}
// needleAddr returns the configured or default address for the Needle 3 sidecar.
func needleAddr() string {
addr := os.Getenv("OTEL_NEEDLE_ADDR")