(w http.ResponseWriter, req *http.Request)
| 97 | } |
| 98 | |
| 99 | func (h *PrometheusHighMetricsHandler) ServeHTTP(w http.ResponseWriter, |
| 100 | req *http.Request) { |
| 101 | initNsServerCaching(h.mgr) |
| 102 | |
| 103 | rd := getRecentInfo() |
| 104 | if rd.err != nil { |
| 105 | rest.ShowError(w, req, fmt.Sprintf("could not retrieve defs: %v", rd.err), |
| 106 | http.StatusInternalServerError) |
| 107 | return |
| 108 | } |
| 109 | |
| 110 | nsIndexStats, err := gatherIndexStats(h.mgr, rd, true) |
| 111 | if err != nil { |
| 112 | rest.ShowError(w, req, fmt.Sprintf("error in retrieving defs: %v", err), |
| 113 | http.StatusInternalServerError) |
| 114 | return |
| 115 | } |
| 116 | |
| 117 | w.Header().Set("Cache-Control", "no-cache") |
| 118 | w.Header().Set("Content-Type", "text/plain; charset=utf-8") |
| 119 | |
| 120 | for k, nsis := range nsIndexStats { |
| 121 | for nsik, nsiv := range nsis { |
| 122 | b, err := json.Marshal(nsiv) |
| 123 | if err != nil { |
| 124 | rest.ShowError(w, req, fmt.Sprintf("json marshal err: %v", err), |
| 125 | http.StatusInternalServerError) |
| 126 | return |
| 127 | } |
| 128 | if typ, ok := prometheusStats[nsik]; ok { |
| 129 | w.Write([]byte(fmt.Sprintf("# TYPE fts_%s %s\n", nsik, typ))) |
| 130 | w.Write(append([]byte("fts_"+nsik+k+" "), b...)) |
| 131 | w.Write(bline) |
| 132 | } |
| 133 | } |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | func scopeCollNames(params, sourceName string) (string, []string) { |
| 138 | tmp := struct { |
nothing calls this directly
no test coverage detected