24 lines
771 B
Go
24 lines
771 B
Go
package prometheus
|
|
|
|
import (
|
|
"net/http/httptest"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestMetricsHandlerExposesBoundedRequestLabels(t *testing.T) {
|
|
metrics := New()
|
|
metrics.ObserveRequest("CUSTOM", "", 599, 25*time.Millisecond)
|
|
|
|
response := httptest.NewRecorder()
|
|
metrics.Handler().ServeHTTP(response, httptest.NewRequest("GET", "/metrics", nil))
|
|
body := response.Body.String()
|
|
if !strings.Contains(body, `lincodex_http_requests_total{method="OTHER",route="unmatched",status="599"} 1`) {
|
|
t.Fatalf("metrics output is missing bounded request labels:\n%s", body)
|
|
}
|
|
if !strings.Contains(body, `lincodex_http_request_duration_seconds_bucket{method="OTHER",route="unmatched",le="0.05"} 1`) {
|
|
t.Fatalf("metrics output is missing request duration:\n%s", body)
|
|
}
|
|
}
|