Skip to content

Commit 28615e2

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

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
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.

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ require (
4646
github.com/emirpasic/gods v1.18.1
4747
github.com/ethantkoenig/rupture v1.0.1
4848
github.com/felixge/fgprof v0.9.5
49+
github.com/felixge/httpsnoop v1.0.4
4950
github.com/fsnotify/fsnotify v1.7.0
5051
github.com/gliderlabs/ssh v0.3.8
5152
github.com/go-ap/activitypub v0.0.0-20240910141749-b4b8c8aa484c
@@ -99,6 +100,7 @@ require (
99100
github.com/pkg/errors v0.9.1
100101
github.com/pquerna/otp v1.4.0
101102
github.com/prometheus/client_golang v1.20.5
103+
github.com/prometheus/common v0.60.1
102104
github.com/quasoft/websspi v1.1.2
103105
github.com/redis/go-redis/v9 v9.7.0
104106
github.com/robfig/cron/v3 v3.0.1
@@ -193,7 +195,6 @@ require (
193195
github.com/dlclark/regexp2 v1.11.4 // indirect
194196
github.com/emersion/go-sasl v0.0.0-20241020182733-b788ff22d5a6 // indirect
195197
github.com/fatih/color v1.18.0 // indirect
196-
github.com/felixge/httpsnoop v1.0.4 // indirect
197198
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
198199
github.com/git-lfs/pktline v0.0.0-20230103162542-ca444d533ef1 // indirect
199200
github.com/go-ap/errors v0.0.0-20240910140019-1e9d33cc1568 // indirect
@@ -268,7 +269,6 @@ require (
268269
github.com/pjbgf/sha1cd v0.3.1 // indirect
269270
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
270271
github.com/prometheus/client_model v0.6.1 // indirect
271-
github.com/prometheus/common v0.60.1 // indirect
272272
github.com/prometheus/procfs v0.15.1 // indirect
273273
github.com/rhysd/actionlint v1.7.3 // indirect
274274
github.com/rivo/uniseg v0.4.7 // indirect

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)