Properly register boulder-wfe2 http metrics (#4654)

Instead of blackholing them.
This commit is contained in:
Roland Bracewell Shoemaker 2020-01-21 12:55:26 -08:00 committed by Jacob Hoffman-Andrews
parent 1be1986894
commit 87746dec5c
2 changed files with 36 additions and 2 deletions

View File

@ -19,7 +19,6 @@ import (
"github.com/letsencrypt/boulder/goodkey"
bgrpc "github.com/letsencrypt/boulder/grpc"
blog "github.com/letsencrypt/boulder/log"
"github.com/letsencrypt/boulder/metrics"
noncepb "github.com/letsencrypt/boulder/nonce/proto"
rapb "github.com/letsencrypt/boulder/ra/proto"
sapb "github.com/letsencrypt/boulder/sa/proto"
@ -307,7 +306,7 @@ func main() {
logger.Infof("WFE using key policy: %#v", kp)
logger.Infof("Server running, listening on %s...\n", c.WFE.ListenAddress)
handler := wfe.Handler(metrics.NoopRegisterer)
handler := wfe.Handler(stats)
srv := &http.Server{
Addr: c.WFE.ListenAddress,
Handler: handler,

View File

@ -3,6 +3,7 @@
package integration
import (
"io/ioutil"
"net/http"
"testing"
@ -29,3 +30,37 @@ func TestWFECORS(t *testing.T) {
corsAllowOrigin := resp.Header.Get("Access-Control-Allow-Origin")
test.AssertEquals(t, corsAllowOrigin, "*")
}
// TestWFEHTTPMetrics verifies that the measured_http metrics we collect
// for boulder-wfe and boulder-wfe2 are being properly collected. In order
// to initialize the prometheus metrics we make a call to the /directory
// endpoint before checking the /metrics endpoint.
func TestWFEHTTPMetrics(t *testing.T) {
// Check boulder-wfe2
resp, err := http.Get("http://boulder:4001/directory")
test.AssertNotError(t, err, "GET boulder-wfe2 directory")
test.AssertEquals(t, resp.StatusCode, http.StatusOK)
resp.Body.Close()
resp, err = http.Get("http://boulder:8013/metrics")
test.AssertNotError(t, err, "GET boulder-wfe2 metrics")
test.AssertEquals(t, resp.StatusCode, http.StatusOK)
body, err := ioutil.ReadAll(resp.Body)
test.AssertNotError(t, err, "Reading boulder-wfe2 metrics response")
test.AssertContains(t, string(body), `response_time_count{code="200",endpoint="/directory",method="GET"}`)
resp.Body.Close()
// Check boulder-wfe
resp, err = http.Get("http://boulder:4000/directory")
test.AssertNotError(t, err, "GET boulder-wfe directory")
test.AssertEquals(t, resp.StatusCode, http.StatusOK)
resp.Body.Close()
resp, err = http.Get("http://boulder:8000/metrics")
test.AssertNotError(t, err, "GET boulder-wfe metrics")
test.AssertEquals(t, resp.StatusCode, http.StatusOK)
body, err = ioutil.ReadAll(resp.Body)
test.AssertNotError(t, err, "Reading boulder-wfe metrics response")
test.AssertContains(t, string(body), `response_time_count{code="200",endpoint="/directory",method="GET"}`)
resp.Body.Close()
}