@cryptotaxi247 / kubo / commits / d460150f4

gateway: label get requests latency with the path namespace

Steven Allen committed Jun 4, 2019 at 17:34 UTC d460150f4382b6439bd13c886d725b382ef6542f
2 files changed +4 -3
core/corehttp/gateway_handler.go
+2 -1
@@ -173,7 +173,8 @@ 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())
176 +
177 + unixfsGetMetric.WithLabelValues(parsedPath.Namespace()).Observe(time.Since(begin).Seconds())
178
179 defer dr.Close()
180
core/corehttp/metrics.go
+2 -2
@@ -98,12 +98,12 @@ var (
98 prometheus.BuildFQName("ipfs", "p2p", "peers_total"),
99 "Number of connected peers", []string{"transport"}, nil)
100
101 - unixfsGetMetric = prometheus.NewSummary(prometheus.SummaryOpts{
101 + unixfsGetMetric = prometheus.NewSummaryVec(prometheus.SummaryOpts{
102 Namespace: "ipfs",
103 Subsystem: "http",
104 Name: "unixfs_get_latency_seconds",
105 Help: "The time till the first block is received when 'getting' a file from the gateway.",
106 - })
106 + }, []string{"namespace"})
107 )
108
109 type IpfsNodeCollector struct {