initial commit
This commit is contained in:
commit
88c14b627e
224 files changed
+17204
No files matched your search
@@ -0,0 +1,23 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user