Merge branch 'master' into rbf-fix-checkpoint

This commit is contained in:
jaten-molecula 2020-09-14 13:58:24 -04:00 committed by GitHub
commit d0ce2e1207
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View file

@ -1632,10 +1632,10 @@ func (h *Handler) handleGetMetricsJSON(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
metrics := make(map[string][]*prom2json.Family)
mfChan := make(chan *dto.MetricFamily, 60)
transport := http.DefaultTransport.(*http.Transport).Clone()
for _, node := range h.api.Hosts(r.Context()) {
metricsURI := node.URI.String() + "/metrics"
mfChan := make(chan *dto.MetricFamily, 60)
err := prom2json.FetchMetricFamilies(metricsURI, mfChan, transport)
if err != nil {
http.Error(w, "fetching metrics: "+err.Error(), http.StatusInternalServerError)

View file

@ -381,6 +381,23 @@ func TestHandler_Endpoints(t *testing.T) {
}
})
t.Run("Metrics", func(t *testing.T) {
w := httptest.NewRecorder()
h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/metrics", nil))
if w.Code != gohttp.StatusOK {
t.Fatalf("unexpected status code: %d", w.Code)
}
})
t.Run("Metrics.json", func(t *testing.T) {
w := httptest.NewRecorder()
h.ServeHTTP(w, test.MustNewHTTPRequest("GET", "/metrics.json", nil))
if w.Code != gohttp.StatusOK {
t.Fatalf("unexpected status code: %d", w.Code)
}
mustJSONDecode(t, w.Body)
})
t.Run("Abort no resize job", func(t *testing.T) {
w := httptest.NewRecorder()
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", "/cluster/resize/abort", nil))