Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
changes as per review
Browse files Browse the repository at this point in the history
  • Loading branch information
aarshkshah1992 committed Apr 7, 2023
1 parent 134f74e commit aaa8ca2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
8 changes: 0 additions & 8 deletions caboose.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,6 @@ func (c *Caboose) Close() {

// Fetch allows fetching car archives by a path of the form `/ipfs/<cid>[/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))
}

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down Expand Up @@ -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()
}
Expand Down

0 comments on commit aaa8ca2

Please sign in to comment.