Skip to content
Permalink
Browse files

#11 generate metric full name with prometheus.BuildFQName()

  • Loading branch information
sevennt committed Oct 28, 2019
1 parent 989b455 commit 3257f60847a3953a74e80c00192845c134612223
Showing with 7 additions and 7 deletions.
  1. +7 −7 prom_test.go
@@ -146,15 +146,15 @@ func TestInstrument(t *testing.T) {
g := gofight.New()
g.GET(p.MetricsPath).Run(r, func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
assert.Equal(t, http.StatusOK, r.Code)
assert.NotContains(t, r.Body.String(), fmt.Sprintf("%s_requests_total", p.Subsystem))
assert.NotContains(t, r.Body.String(), prometheus.BuildFQName(p.Namespace, p.Subsystem, "requests_total"))
assert.NotContains(t, r.Body.String(), lpath, "path must not be present in the response")
})

g.GET("/user/10").Run(r, func(r gofight.HTTPResponse, rq gofight.HTTPRequest) { assert.Equal(t, http.StatusOK, r.Code) })

g.GET(p.MetricsPath).Run(r, func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
assert.Equal(t, http.StatusOK, r.Code)
assert.Contains(t, r.Body.String(), fmt.Sprintf("%s_requests_total", p.Subsystem))
assert.Contains(t, r.Body.String(), prometheus.BuildFQName(p.Namespace, p.Subsystem, "requests_total"))
assert.Contains(t, r.Body.String(), lpath, "path must be present in the response")
assert.NotContains(t, r.Body.String(), `path="/user/10"`, "raw path must not be present")
})
@@ -182,7 +182,7 @@ func TestThreadedInstrument(t *testing.T) {

g.GET(p.MetricsPath).Run(r, func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
assert.Equal(t, http.StatusOK, r.Code)
assert.Contains(t, r.Body.String(), fmt.Sprintf("%s_requests_total", p.Subsystem))
assert.Contains(t, r.Body.String(), prometheus.BuildFQName(p.Namespace, p.Subsystem, "requests_total"))
assert.Contains(t, r.Body.String(), lpath, "path must be present in the response")
assert.NotContains(t, r.Body.String(), `path="/user/10"`, "raw path must not be present")
})
@@ -222,14 +222,14 @@ func TestIgnore(t *testing.T) {
g := gofight.New()
g.GET(p.MetricsPath).Run(r, func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
assert.Equal(t, http.StatusOK, r.Code)
assert.NotContains(t, r.Body.String(), fmt.Sprintf("%s_requests_total", p.Subsystem))
assert.NotContains(t, r.Body.String(), prometheus.BuildFQName(p.Namespace, p.Subsystem, "requests_total"))
})

g.GET("/ping").Run(r, func(r gofight.HTTPResponse, rq gofight.HTTPRequest) { assert.Equal(t, http.StatusOK, r.Code) })

g.GET(p.MetricsPath).Run(r, func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
assert.Equal(t, http.StatusOK, r.Code)
assert.NotContains(t, r.Body.String(), fmt.Sprintf("%s_requests_total", p.Subsystem))
assert.NotContains(t, r.Body.String(), prometheus.BuildFQName(p.Namespace, p.Subsystem, "requests_total"))
assert.NotContains(t, r.Body.String(), lipath, "ignored path must not be present")
})
unregister(p)
@@ -243,7 +243,7 @@ func TestMetricsPathIgnored(t *testing.T) {
g := gofight.New()
g.GET(p.MetricsPath).Run(r, func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
assert.Equal(t, http.StatusOK, r.Code)
assert.NotContains(t, r.Body.String(), fmt.Sprintf("%s_requests_total", p.Subsystem))
assert.NotContains(t, r.Body.String(), prometheus.BuildFQName(p.Namespace, p.Subsystem, "requests_total"))
})
unregister(p)
}
@@ -275,7 +275,7 @@ func TestMetricsBearerToken(t *testing.T) {
}).
Run(r, func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
assert.Equal(t, http.StatusOK, r.Code)
assert.NotContains(t, r.Body.String(), fmt.Sprintf("%s_requests_total", p.Subsystem))
assert.NotContains(t, r.Body.String(), prometheus.BuildFQName(p.Namespace, p.Subsystem, "requests_total"))
})
unregister(p)
}

0 comments on commit 3257f60

Please sign in to comment.
You can’t perform that action at this time.