volume server: adds basic metrics

This commit is contained in:
Chris Lu
2019-06-14 00:54:56 -07:00
parent a11525fe4e
commit 5f6c9825f8
7 changed files with 61 additions and 8 deletions

View File

@@ -15,6 +15,11 @@ import (
)
func (vs *VolumeServer) PostHandler(w http.ResponseWriter, r *http.Request) {
volumeServerRequestCounter.WithLabelValues("post").Inc()
start := time.Now()
defer func() { volumeServerHistogram.WithLabelValues("post").Observe(time.Since(start).Seconds()) }()
if e := r.ParseForm(); e != nil {
glog.V(0).Infoln("form parse error:", e)
writeJsonError(w, r, http.StatusBadRequest, e)
@@ -60,6 +65,11 @@ func (vs *VolumeServer) PostHandler(w http.ResponseWriter, r *http.Request) {
}
func (vs *VolumeServer) DeleteHandler(w http.ResponseWriter, r *http.Request) {
volumeServerRequestCounter.WithLabelValues("delete").Inc()
start := time.Now()
defer func() { volumeServerHistogram.WithLabelValues("delete").Observe(time.Since(start).Seconds()) }()
n := new(needle.Needle)
vid, fid, _, _, _ := parseURLPath(r.URL.Path)
volumeId, _ := needle.NewVolumeId(vid)