summaryrefslogtreecommitdiff
path: root/metrics.go
diff options
context:
space:
mode:
Diffstat (limited to 'metrics.go')
-rw-r--r--metrics.go16
1 files changed, 3 insertions, 13 deletions
diff --git a/metrics.go b/metrics.go
index ab9d797..325006f 100644
--- a/metrics.go
+++ b/metrics.go
@@ -2,9 +2,8 @@ package caddy
import (
"net/http"
- "strconv"
- "strings"
+ "github.com/caddyserver/caddy/v2/internal/metrics"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/collectors"
"github.com/prometheus/client_golang/prometheus/promauto"
@@ -46,8 +45,8 @@ func instrumentHandlerCounter(counter *prometheus.CounterVec, next http.Handler)
d := newDelegator(w)
next.ServeHTTP(d, r)
counter.With(prometheus.Labels{
- "code": sanitizeCode(d.status),
- "method": strings.ToUpper(r.Method),
+ "code": metrics.SanitizeCode(d.status),
+ "method": metrics.SanitizeMethod(r.Method),
}).Inc()
})
}
@@ -67,12 +66,3 @@ func (d *delegator) WriteHeader(code int) {
d.status = code
d.ResponseWriter.WriteHeader(code)
}
-
-func sanitizeCode(s int) string {
- switch s {
- case 0, 200:
- return "200"
- default:
- return strconv.Itoa(s)
- }
-}