MCPcopy Index your code
hub / github.com/cortexproject/cortex / AllUserStatsRender

Function AllUserStatsRender

pkg/ingester/http_admin.go:98–120  ·  view source on GitHub ↗

AllUserStatsRender render data for all users or return in json format.

(w http.ResponseWriter, r *http.Request, stats []UserIDStats, rf, queriedIngesterNum int)

Source from the content-addressed store, hash-verified

96
97// AllUserStatsRender render data for all users or return in json format.
98func AllUserStatsRender(w http.ResponseWriter, r *http.Request, stats []UserIDStats, rf, queriedIngesterNum int) {
99 sort.Sort(UserStatsByTimeseries(stats))
100
101 if encodings, found := r.Header["Accept"]; found &&
102 len(encodings) > 0 && strings.Contains(encodings[0], "json") {
103 if err := json.NewEncoder(w).Encode(stats); err != nil {
104 http.Error(w, fmt.Sprintf("Error marshalling response: %v", err), http.StatusInternalServerError)
105 }
106 return
107 }
108
109 util.RenderHTTPResponse(w, struct {
110 Now time.Time `json:"now"`
111 Stats []UserIDStats `json:"stats"`
112 ReplicationFactor int `json:"replicationFactor"`
113 QueriedIngesterNum int `json:"queriedIngesterNum"`
114 }{
115 Now: time.Now(),
116 Stats: stats,
117 ReplicationFactor: rf,
118 QueriedIngesterNum: queriedIngesterNum,
119 }, UserStatsTmpl, r)
120}

Callers 3

AllUserStatsHandlerMethod · 0.92
AllUserStatsHandlerMethod · 0.85

Calls 4

RenderHTTPResponseFunction · 0.92
UserStatsByTimeseriesTypeAlias · 0.85
EncodeMethod · 0.65
ErrorMethod · 0.45

Tested by 1