@@ -22,18 +22,18 @@ func Prometheus(register prometheus.Registerer) func(http.Handler) http.Handler
22
22
Name : "requests_processed_total" ,
23
23
Help : "The total number of processed API requests" ,
24
24
}, []string {"code" , "method" , "path" })
25
- requestsConcurrent := factory .NewGauge (prometheus.GaugeOpts {
25
+ requestsConcurrent := factory .NewGaugeVec (prometheus.GaugeOpts {
26
26
Namespace : "coderd" ,
27
27
Subsystem : "api" ,
28
28
Name : "concurrent_requests" ,
29
29
Help : "The number of concurrent API requests." ,
30
- })
31
- websocketsConcurrent := factory .NewGauge (prometheus.GaugeOpts {
30
+ }, [] string { "path" } )
31
+ websocketsConcurrent := factory .NewGaugeVec (prometheus.GaugeOpts {
32
32
Namespace : "coderd" ,
33
33
Subsystem : "api" ,
34
34
Name : "concurrent_websockets" ,
35
35
Help : "The total number of concurrent API websockets." ,
36
- })
36
+ }, [] string { "path" } )
37
37
websocketsDist := factory .NewHistogramVec (prometheus.HistogramOpts {
38
38
Namespace : "coderd" ,
39
39
Subsystem : "api" ,
@@ -69,27 +69,28 @@ func Prometheus(register prometheus.Registerer) func(http.Handler) http.Handler
69
69
panic ("dev error: http.ResponseWriter is not *tracing.StatusWriter" )
70
70
}
71
71
72
+ path := rctx .RoutePattern ()
73
+
72
74
var (
73
75
dist * prometheus.HistogramVec
74
76
distOpts []string
75
77
)
76
78
// We want to count WebSockets separately.
77
79
if httpapi .IsWebsocketUpgrade (r ) {
78
- websocketsConcurrent .Inc ()
79
- defer websocketsConcurrent .Dec ()
80
+ websocketsConcurrent .WithLabelValues ( path ). Inc ()
81
+ defer websocketsConcurrent .WithLabelValues ( path ). Dec ()
80
82
81
83
dist = websocketsDist
82
84
} else {
83
- requestsConcurrent .Inc ()
84
- defer requestsConcurrent .Dec ()
85
+ requestsConcurrent .WithLabelValues ( path ). Inc ()
86
+ defer requestsConcurrent .WithLabelValues ( path ). Dec ()
85
87
86
88
dist = requestsDist
87
89
distOpts = []string {method }
88
90
}
89
91
90
92
next .ServeHTTP (w , r )
91
93
92
- path := rctx .RoutePattern ()
93
94
distOpts = append (distOpts , path )
94
95
statusStr := strconv .Itoa (sw .Status )
95
96
0 commit comments