aboutsummaryrefslogtreecommitdiff
path: root/weed/server/filer_server_handlers_read.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2019-06-13 02:01:51 -0700
committerChris Lu <chris.lu@gmail.com>2019-06-13 02:01:54 -0700
commita11525fe4eb501f4c98db6aaf40800edabf30d08 (patch)
tree402552f42955055eff7c09d06fbeb0a2a9d3389f /weed/server/filer_server_handlers_read.go
parentc542714448cff02e72ddc75f30712c24c3b3024f (diff)
downloadseaweedfs-a11525fe4eb501f4c98db6aaf40800edabf30d08.tar.xz
seaweedfs-a11525fe4eb501f4c98db6aaf40800edabf30d08.zip
filer: adds basic metrics pushing to Prometheus gateway
Diffstat (limited to 'weed/server/filer_server_handlers_read.go')
-rw-r--r--weed/server/filer_server_handlers_read.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/weed/server/filer_server_handlers_read.go b/weed/server/filer_server_handlers_read.go
index 663bf4b58..ca6269fd1 100644
--- a/weed/server/filer_server_handlers_read.go
+++ b/weed/server/filer_server_handlers_read.go
@@ -11,6 +11,7 @@ import (
"path"
"strconv"
"strings"
+ "time"
"github.com/chrislusf/seaweedfs/weed/filer2"
"github.com/chrislusf/seaweedfs/weed/glog"
@@ -18,6 +19,11 @@ import (
)
func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request, isGetMethod bool) {
+
+ filerRequestCounter.WithLabelValues("get").Inc()
+ start := time.Now()
+ defer func() { filerRequestHistogram.WithLabelValues("get").Observe(time.Since(start).Seconds()) }()
+
path := r.URL.Path
if strings.HasSuffix(path, "/") && len(path) > 1 {
path = path[:len(path)-1]
@@ -30,6 +36,8 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request,
return
}
glog.V(1).Infof("Not found %s: %v", path, err)
+
+ filerRequestCounter.WithLabelValues("read.notfound").Inc()
w.WriteHeader(http.StatusNotFound)
return
}
@@ -45,6 +53,7 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request,
if len(entry.Chunks) == 0 {
glog.V(1).Infof("no file chunks for %s, attr=%+v", path, entry.Attr)
+ filerRequestCounter.WithLabelValues("read.nocontent").Inc()
w.WriteHeader(http.StatusNoContent)
return
}