aboutsummaryrefslogtreecommitdiff
path: root/weed/server/volume_server_handlers.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/server/volume_server_handlers.go')
-rw-r--r--weed/server/volume_server_handlers.go20
1 files changed, 15 insertions, 5 deletions
diff --git a/weed/server/volume_server_handlers.go b/weed/server/volume_server_handlers.go
index 9523eee56..06134e648 100644
--- a/weed/server/volume_server_handlers.go
+++ b/weed/server/volume_server_handlers.go
@@ -31,6 +31,8 @@ security settings:
*/
func (vs *VolumeServer) privateStoreHandler(w http.ResponseWriter, r *http.Request) {
+ statusRecorder := stats.NewStatusResponseWriter(w)
+ w = statusRecorder
w.Header().Set("Server", "SeaweedFS Volume "+util.VERSION)
if r.Header.Get("Origin") != "" {
w.Header().Set("Access-Control-Allow-Origin", "*")
@@ -38,10 +40,10 @@ func (vs *VolumeServer) privateStoreHandler(w http.ResponseWriter, r *http.Reque
}
start := time.Now()
requestMethod := r.Method
- defer func(start time.Time, method *string) {
- stats.VolumeServerRequestCounter.WithLabelValues(*method).Inc()
+ defer func(start time.Time, method *string, statusRecorder *stats.StatusRecorder) {
+ stats.VolumeServerRequestCounter.WithLabelValues(*method, strconv.Itoa(statusRecorder.Status)).Inc()
stats.VolumeServerRequestHistogram.WithLabelValues(*method).Observe(time.Since(start).Seconds())
- }(start, &requestMethod)
+ }(start, &requestMethod, statusRecorder)
switch r.Method {
case http.MethodGet, http.MethodHead:
stats.ReadRequest()
@@ -63,11 +65,9 @@ func (vs *VolumeServer) privateStoreHandler(w http.ResponseWriter, r *http.Reque
vs.inFlightDownloadDataLimitCond.L.Unlock()
vs.GetOrHeadHandler(w, r)
case http.MethodDelete:
- stats.VolumeServerRequestCounter.WithLabelValues(r.Method).Inc()
stats.DeleteRequest()
vs.guard.WhiteList(vs.DeleteHandler)(w, r)
case http.MethodPut, http.MethodPost:
- stats.VolumeServerRequestCounter.WithLabelValues(r.Method).Inc()
contentLength := getContentLength(r)
// exclude the replication from the concurrentUploadLimitMB
if r.URL.Query().Get("type") != "replicate" && vs.concurrentUploadLimit != 0 {
@@ -124,11 +124,21 @@ func getContentLength(r *http.Request) int64 {
}
func (vs *VolumeServer) publicReadOnlyHandler(w http.ResponseWriter, r *http.Request) {
+ statusRecorder := stats.NewStatusResponseWriter(w)
+ w = statusRecorder
w.Header().Set("Server", "SeaweedFS Volume "+util.VERSION)
if r.Header.Get("Origin") != "" {
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Access-Control-Allow-Credentials", "true")
}
+
+ start := time.Now()
+ requestMethod := r.Method
+ defer func(start time.Time, method *string, statusRecorder *stats.StatusRecorder) {
+ stats.VolumeServerRequestCounter.WithLabelValues(*method, strconv.Itoa(statusRecorder.Status)).Inc()
+ stats.VolumeServerRequestHistogram.WithLabelValues(*method).Observe(time.Since(start).Seconds())
+ }(start, &requestMethod, statusRecorder)
+
switch r.Method {
case http.MethodGet, http.MethodHead:
stats.ReadRequest()