add unixfs get metric
License: MIT Signed-off-by: whyrusleeping <why@ipfs.io>
whyrusleeping committed
Jun 4, 2019 at 16:48 UTC
846b6b5d9523ba2a859370b48fa8bb20d918d08b
2 files changed
+5
core/corehttp/gateway_handler.go
+2
@@ -123,6 +123,7 @@ func (i *gatewayHandler) optionsHandler(w http.ResponseWriter, r *http.Request)
123
}
124
125
func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request) {
126
+ begin := time.Now()
127
urlPath := r.URL.Path
128
escapedURLPath := r.URL.EscapedPath()
129
@@ -172,6 +173,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request
173
webError(w, "ipfs cat "+escapedURLPath, err, http.StatusNotFound)
174
return
175
}
176
+ unixfsGetMetric.Observe(time.Since(begin).Seconds())
177
178
defer dr.Close()
179
core/corehttp/metrics.go
+3
@@ -97,6 +97,9 @@ var (
97
peersTotalMetric = prometheus.NewDesc(
98
prometheus.BuildFQName("ipfs", "p2p", "peers_total"),
99
"Number of connected peers", []string{"transport"}, nil)
100
+ unixfsGetMetric = prometheus.NewSummary(prometheus.SummaryOpts{
101
+ Name: "unixfsGet",
102
+ })
103
)
104
105
type IpfsNodeCollector struct {