diff options
Diffstat (limited to 'weed/stats')
| -rw-r--r-- | weed/stats/http_status_recorder.go | 21 | ||||
| -rw-r--r-- | weed/stats/metrics.go | 18 |
2 files changed, 39 insertions, 0 deletions
diff --git a/weed/stats/http_status_recorder.go b/weed/stats/http_status_recorder.go new file mode 100644 index 000000000..19467ecf2 --- /dev/null +++ b/weed/stats/http_status_recorder.go @@ -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() +} diff --git a/weed/stats/metrics.go b/weed/stats/metrics.go index 87e5f2f4e..49a3b090b 100644 --- a/weed/stats/metrics.go +++ b/weed/stats/metrics.go @@ -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) |
