aboutsummaryrefslogtreecommitdiff
path: root/weed/s3api/stats.go
diff options
context:
space:
mode:
authorhilimd <68371223+hilimd@users.noreply.github.com>2020-09-22 09:33:25 +0800
committerGitHub <noreply@github.com>2020-09-22 09:33:25 +0800
commit082500151a85f4d59a9f779174bcb3043b723272 (patch)
treef423c694d8f6af15d59ab1c4401d3e80fac876c3 /weed/s3api/stats.go
parentf71f7fcf99ba6d64bfa49fd7411e06bdc2b9d591 (diff)
parent9cdbfc1a4987bdb46f16ae37624ed69ef66778a9 (diff)
downloadseaweedfs-082500151a85f4d59a9f779174bcb3043b723272.tar.xz
seaweedfs-082500151a85f4d59a9f779174bcb3043b723272.zip
Merge pull request #16 from chrislusf/master
sync
Diffstat (limited to 'weed/s3api/stats.go')
-rw-r--r--weed/s3api/stats.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/weed/s3api/stats.go b/weed/s3api/stats.go
new file mode 100644
index 000000000..16a546c66
--- /dev/null
+++ b/weed/s3api/stats.go
@@ -0,0 +1,21 @@
+package s3api
+
+import (
+ stats_collect "github.com/chrislusf/seaweedfs/weed/stats"
+ "github.com/chrislusf/seaweedfs/weed/util"
+ "net/http"
+ "time"
+)
+
+func track(f http.HandlerFunc, action string) http.HandlerFunc {
+
+ return func(w http.ResponseWriter, r *http.Request) {
+
+ w.Header().Set("Server", "SeaweedFS S3 "+util.VERSION)
+
+ start := time.Now()
+ stats_collect.S3RequestCounter.WithLabelValues(action).Inc()
+ f(w, r)
+ stats_collect.S3RequestHistogram.WithLabelValues(action).Observe(time.Since(start).Seconds())
+ }
+}