Skip to content

Commit cc06fe3

Browse files
committed
fix(metrics): fallback to legacy naming
1 parent bf12d56 commit cc06fe3

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

assets/go-licenses.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

routers/common/middleware.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,35 +24,41 @@ import (
2424
"github.com/prometheus/client_golang/prometheus/promauto"
2525
)
2626

27+
const (
28+
httpRequestMethod = "http_request_method"
29+
httpResponseStatusCode = "http_response_status_code"
30+
httpRoute = "http_route"
31+
)
32+
2733
var (
2834
// reqInflightGauge tracks the amount of currently handled requests
2935
reqInflightGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{
3036
Namespace: "http",
3137
Subsystem: "server",
3238
Name: "active_requests",
3339
Help: "Number of active HTTP server requests.",
34-
}, []string{"http.request.method"})
40+
}, []string{httpRequestMethod})
3541
// reqDurationHistogram tracks the time taken by http request
3642
reqDurationHistogram = promauto.NewHistogramVec(prometheus.HistogramOpts{
3743
Namespace: "http",
3844
Subsystem: "server",
3945
Name: "request_duration",
4046
Help: "Measures the latency of HTTP requests processed by the server",
41-
}, []string{"http.request.method", "http.response.status_code", "http.route"})
47+
}, []string{httpRequestMethod, httpResponseStatusCode, httpRoute})
4248
// reqSizeHistogram tracks the size of request
4349
reqSizeHistogram = promauto.NewHistogramVec(prometheus.HistogramOpts{
4450
Namespace: "http",
4551
Subsystem: "server_request",
4652
Name: "body_size",
4753
Help: "Size of HTTP server request bodies.",
48-
}, []string{"http.request.method", "http.response.status_code", "http.route"})
54+
}, []string{httpRequestMethod, httpResponseStatusCode, httpRoute})
4955
// respSizeHistogram tracks the size of the response
5056
respSizeHistogram = promauto.NewHistogramVec(prometheus.HistogramOpts{
5157
Namespace: "http",
5258
Subsystem: "server_response",
5359
Name: "body_size",
5460
Help: "Size of HTTP server response bodies.",
55-
}, []string{"http.request.method", "http.response.status_code", "http.route"})
61+
}, []string{httpRequestMethod, httpResponseStatusCode, httpRoute})
5662
)
5763

5864
// ProtocolMiddlewares returns HTTP protocol related middlewares, and it provides a global panic recovery

0 commit comments

Comments
 (0)