(w http.ResponseWriter, req *http.Request)
| 199 | } |
| 200 | |
| 201 | func (h *PrometheusMetricsHandler) ServeHTTP(w http.ResponseWriter, |
| 202 | req *http.Request) { |
| 203 | initNsServerCaching(h.mgr) |
| 204 | |
| 205 | rd := getRecentInfo() |
| 206 | if rd.err != nil { |
| 207 | rest.ShowError(w, req, fmt.Sprintf("could not retrieve defs: %v", rd.err), |
| 208 | http.StatusInternalServerError) |
| 209 | return |
| 210 | } |
| 211 | |
| 212 | w.Header().Set("Cache-Control", "no-cache") |
| 213 | w.Header().Set("Content-Type", "text/plain; charset=utf-8") |
| 214 | |
| 215 | stats := gatherTopLevelStats(rd) |
| 216 | for k, v := range stats { |
| 217 | b, err := json.Marshal(v) |
| 218 | if err != nil { |
| 219 | rest.ShowError(w, req, fmt.Sprintf("json marshal err: %v", err), |
| 220 | http.StatusInternalServerError) |
| 221 | return |
| 222 | } |
| 223 | if typ, ok := prometheusStats[k]; ok { |
| 224 | w.Write([]byte(fmt.Sprintf("# TYPE fts_%s %s\n", k, typ))) |
| 225 | w.Write(append([]byte("fts_"+k+" "), b...)) |
| 226 | w.Write(bline) |
| 227 | } |
| 228 | } |
| 229 | } |
nothing calls this directly
no test coverage detected