chore: add status code for request_total metrics (#5188)
This commit is contained in:
committed by
GitHub
parent
fe417ee02d
commit
a7fc723ae0
21
weed/stats/http_status_recorder.go
Normal file
21
weed/stats/http_status_recorder.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package stats
|
||||
|
||||
import "net/http"
|
||||
|
||||
type StatusRecorder struct {
|
||||
http.ResponseWriter
|
||||
Status int
|
||||
}
|
||||
|
||||
func NewStatusResponseWriter(w http.ResponseWriter) *StatusRecorder {
|
||||
return &StatusRecorder{w, http.StatusOK}
|
||||
}
|
||||
|
||||
func (r *StatusRecorder) WriteHeader(status int) {
|
||||
r.Status = status
|
||||
r.ResponseWriter.WriteHeader(status)
|
||||
}
|
||||
|
||||
func (r *StatusRecorder) Flush() {
|
||||
r.ResponseWriter.(http.Flusher).Flush()
|
||||
}
|
||||
@@ -84,6 +84,14 @@ var (
|
||||
Subsystem: "filer",
|
||||
Name: "request_total",
|
||||
Help: "Counter of filer requests.",
|
||||
}, []string{"type", "code"})
|
||||
|
||||
FilerHandlerCounter = prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Namespace: Namespace,
|
||||
Subsystem: "filer",
|
||||
Name: "handler_total",
|
||||
Help: "Counter of filer handlers.",
|
||||
}, []string{"type"})
|
||||
|
||||
FilerRequestHistogram = prometheus.NewHistogramVec(
|
||||
@@ -134,6 +142,14 @@ var (
|
||||
Subsystem: "volumeServer",
|
||||
Name: "request_total",
|
||||
Help: "Counter of volume server requests.",
|
||||
}, []string{"type", "code"})
|
||||
|
||||
VolumeServerHandlerCounter = prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Namespace: Namespace,
|
||||
Subsystem: "volumeServer",
|
||||
Name: "handler_total",
|
||||
Help: "Counter of volume server handlers.",
|
||||
}, []string{"type"})
|
||||
|
||||
VolumeServerVacuumingCompactCounter = prometheus.NewCounterVec(
|
||||
@@ -245,6 +261,7 @@ func init() {
|
||||
Gather.MustRegister(MasterReplicaPlacementMismatch)
|
||||
|
||||
Gather.MustRegister(FilerRequestCounter)
|
||||
Gather.MustRegister(FilerHandlerCounter)
|
||||
Gather.MustRegister(FilerRequestHistogram)
|
||||
Gather.MustRegister(FilerStoreCounter)
|
||||
Gather.MustRegister(FilerStoreHistogram)
|
||||
@@ -254,6 +271,7 @@ func init() {
|
||||
Gather.MustRegister(collectors.NewProcessCollector(collectors.ProcessCollectorOpts{}))
|
||||
|
||||
Gather.MustRegister(VolumeServerRequestCounter)
|
||||
Gather.MustRegister(VolumeServerHandlerCounter)
|
||||
Gather.MustRegister(VolumeServerRequestHistogram)
|
||||
Gather.MustRegister(VolumeServerVacuumingCompactCounter)
|
||||
Gather.MustRegister(VolumeServerVacuumingCommitCounter)
|
||||
|
||||
Reference in New Issue
Block a user