more
This commit is contained in:
1 parent
8f670dfa2f
commit
2237fbda55
15 files changed
+594
-52
No files matched your search
@@ -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")
|
||||
|
||||
Reference in new issue
Block a user