Skip to content

Commit

Permalink
gateway: label get requests latency with the path namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien committed Jun 5, 2019
1 parent ebd89b4 commit d1826e7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion core/corehttp/gateway_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions core/corehttp/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d1826e7

Please sign in to comment.