Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

Commit

Permalink
stream: add set cache metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
acud committed Nov 28, 2019
1 parent 52fb861 commit 8d27364
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions network/stream/sync_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ const (
maxBinZeroSyncPeers = 3
)

var (
setCacheMissCount = metrics.GetOrRegisterCounter("network.stream.sync_provider.set.cachemiss", nil)
setCacheHitCount = metrics.GetOrRegisterCounter("network.stream.sync_provider.set.cachehit", nil)
)

type syncProvider struct {
netStore *storage.NetStore // netstore
kad *network.Kademlia // kademlia
Expand Down Expand Up @@ -204,6 +209,9 @@ func (s *syncProvider) Set(ctx context.Context, addrs ...chunk.Address) error {
for _, addr := range addrs {
if _, ok := s.setCache.Get(addr); !ok {
chunksToSet = append(chunksToSet, addr)
setCacheMissCount.Inc(1)
} else {
setCacheHitCount.Inc(1)
}
}
s.setCacheMtx.RUnlock()
Expand Down

0 comments on commit 8d27364

Please sign in to comment.