File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -29,22 +29,29 @@ func Collector(cfg Config) func(next http.Handler) http.Handler {
29
29
30
30
return func (next http.Handler ) http.Handler {
31
31
fn := func (w http.ResponseWriter , r * http.Request ) {
32
- ww := middleware .NewWrapResponseWriter (w , r .ProtoMajor )
32
+ if r .Method == "GET" {
33
+ if isPathIgnored (r .URL .Path ) {
34
+ next .ServeHTTP (w , r )
35
+ return
36
+ }
37
+ if strings .EqualFold (r .URL .Path , "/metrics" ) {
38
+ // serve metrics page
39
+ metricsHandler .Handler (next ).ServeHTTP (w , r )
40
+ return
41
+ }
42
+ }
33
43
44
+ // measure request
45
+ ww := middleware .NewWrapResponseWriter (w , r .ProtoMajor )
34
46
defer sample (time .Now ().UTC (), r , ww )
35
47
36
- if r .Method == "GET" && isPathIgnored (r .URL .Path ) {
37
- metricsHandler .Handler (next ).ServeHTTP (ww , r )
38
- return
39
- }
40
-
41
48
next .ServeHTTP (ww , r )
42
49
}
43
50
return http .HandlerFunc (fn )
44
51
}
45
52
}
46
53
47
- var ignoredPaths = []string {"/metrics" , "/ ping" , "/status" }
54
+ var ignoredPaths = []string {"/ping" , "/status" }
48
55
49
56
func isPathIgnored (path string ) bool {
50
57
for _ , ignoredPath := range ignoredPaths {
You can’t perform that action at this time.
0 commit comments