From d1826e7d857f50ad90dbad7fc7be195581f0800b Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 4 Jun 2019 17:34:53 -0700 Subject: [PATCH] gateway: label get requests latency with the path namespace --- core/corehttp/gateway_handler.go | 5 ++++- core/corehttp/metrics.go | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/core/corehttp/gateway_handler.go b/core/corehttp/gateway_handler.go index 91bfb19787cf..4dad7bf91262 100644 --- a/core/corehttp/gateway_handler.go +++ b/core/corehttp/gateway_handler.go @@ -173,7 +173,10 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request webError(w, "ipfs cat "+escapedURLPath, err, http.StatusNotFound) return } - unixfsGetMetric.Observe(time.Since(begin).Seconds()) + + unixfsGetMetric.WithLabelValues( + "namespace", parsedPath.Namespace(), + ).Observe(time.Since(begin).Seconds()) defer dr.Close() diff --git a/core/corehttp/metrics.go b/core/corehttp/metrics.go index 7a7f30dd9951..b0aebd3979bf 100644 --- a/core/corehttp/metrics.go +++ b/core/corehttp/metrics.go @@ -98,12 +98,12 @@ var ( prometheus.BuildFQName("ipfs", "p2p", "peers_total"), "Number of connected peers", []string{"transport"}, nil) - unixfsGetMetric = prometheus.NewSummary(prometheus.SummaryOpts{ + 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 {