diff --git a/caboose.go b/caboose.go index 96dfdd8..2c5d6d1 100644 --- a/caboose.go +++ b/caboose.go @@ -256,10 +256,6 @@ func (c *Caboose) Close() { // Fetch allows fetching car archives by a path of the form `/ipfs/[/path/to/file]` func (c *Caboose) Fetch(ctx context.Context, path string, cb DataCallback) error { - fetchCalledTotalMetric.WithLabelValues(resourceTypeCar).Add(1) - if recordIfContextErr(resourceTypeCar, ctx, "FetchApi") { - return ctx.Err() - } return c.pool.fetchResourceWith(ctx, path, cb, c.getAffinity(ctx)) } @@ -272,10 +268,6 @@ func (c *Caboose) Has(ctx context.Context, it cid.Cid) (bool, error) { } func (c *Caboose) Get(ctx context.Context, it cid.Cid) (blocks.Block, error) { - fetchCalledTotalMetric.WithLabelValues(resourceTypeBlock).Add(1) - if recordIfContextErr(resourceTypeBlock, ctx, "FetchBlockApi") { - return nil, ctx.Err() - } blk, err := c.pool.fetchBlockWith(ctx, it, c.getAffinity(ctx)) if err != nil { return nil, err diff --git a/metrics.go b/metrics.go index 50f4a3f..8e7c6f6 100644 --- a/metrics.go +++ b/metrics.go @@ -58,8 +58,8 @@ var ( durationMsPerCarHistogram = prometheus.ExponentialBucketsRange(50, 1800000, 40) // buckets to measure latency between a caboose peer a Saturn L1, - // [50ms, 100ms, 200ms, ..., ~25 seconds] - latencyDistMsHistogram = prometheus.ExponentialBuckets(50, 2, 10) + // [50ms, 75ms, 100ms, ..., 525 ms] + latencyDistMsHistogram = prometheus.LinearBuckets(50, 25, 20) ) // pool metrics diff --git a/pool.go b/pool.go index 1b0f890..abb4a75 100644 --- a/pool.go +++ b/pool.go @@ -342,6 +342,7 @@ func cidToKey(c cid.Cid) string { } func (p *pool) fetchBlockWith(ctx context.Context, c cid.Cid, with string) (blk blocks.Block, err error) { + fetchCalledTotalMetric.WithLabelValues(resourceTypeBlock).Add(1) if recordIfContextErr(resourceTypeBlock, ctx, "fetchBlockWith") { return nil, ctx.Err() } @@ -487,6 +488,7 @@ func (p *pool) getNodesToFetch(key string, with string) ([]string, error) { } func (p *pool) fetchResourceWith(ctx context.Context, path string, cb DataCallback, with string) (err error) { + fetchCalledTotalMetric.WithLabelValues(resourceTypeCar).Add(1) if recordIfContextErr(resourceTypeCar, ctx, "fetchResourceWith") { return ctx.Err() }