diff --git a/core/corehttp/gateway_handler.go b/core/corehttp/gateway_handler.go index 3f212d918..1aa343a55 100644 --- a/core/corehttp/gateway_handler.go +++ b/core/corehttp/gateway_handler.go @@ -123,6 +123,7 @@ func (i *gatewayHandler) optionsHandler(w http.ResponseWriter, r *http.Request) } func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request) { + begin := time.Now() urlPath := r.URL.Path escapedURLPath := r.URL.EscapedPath() @@ -173,6 +174,8 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request return } + unixfsGetMetric.WithLabelValues(parsedPath.Namespace()).Observe(time.Since(begin).Seconds()) + defer dr.Close() // Check etag send back to us diff --git a/core/corehttp/metrics.go b/core/corehttp/metrics.go index 3f8c68ccd..b0aebd397 100644 --- a/core/corehttp/metrics.go +++ b/core/corehttp/metrics.go @@ -97,6 +97,13 @@ var ( peersTotalMetric = prometheus.NewDesc( prometheus.BuildFQName("ipfs", "p2p", "peers_total"), "Number of connected peers", []string{"transport"}, nil) + + unixfsGetMetric = prometheus.NewSummaryVec(prometheus.SummaryOpts{ + Namespace: "ipfs", + Subsystem: "http", + Name: "unixfs_get_latency_seconds", + Help: "The time till the first block is received when 'getting' a file from the gateway.", + }, []string{"namespace"}) ) type IpfsNodeCollector struct {