diff --git a/flytestdlib/fastcheck/iface.go b/flytestdlib/fastcheck/iface.go index 2c285b9b88..0eec7bc7c6 100644 --- a/flytestdlib/fastcheck/iface.go +++ b/flytestdlib/fastcheck/iface.go @@ -3,8 +3,9 @@ package fastcheck import ( "context" + "github.com/prometheus/client_golang/prometheus" + "github.com/flyteorg/flytestdlib/promutils" - "github.com/flyteorg/flytestdlib/promutils/labeled" ) // Filter provides an interface to check if a Key of type []byte was ever seen. @@ -27,14 +28,14 @@ type Filter interface { // Every implementation of the Filter Interface provides these metrics type Metrics struct { // Indicates if the item was found in the cache - Hit labeled.Counter + Hit prometheus.Counter // Indicates if the item was not found in the cache - Miss labeled.Counter + Miss prometheus.Counter } func newMetrics(scope promutils.Scope) Metrics { return Metrics{ - Hit: labeled.NewCounter("cache_hit", "Indicates that the item was found in the cache", scope), - Miss: labeled.NewCounter("cache_miss", "Indicates that the item was found in the cache", scope), + Hit: scope.MustNewCounter("cache_hit", "Indicates that the item was found in the cache"), + Miss: scope.MustNewCounter("cache_miss", "Indicates that the item was found in the cache"), } } diff --git a/flytestdlib/fastcheck/lru.go b/flytestdlib/fastcheck/lru.go index 05360567fc..86c557a46f 100644 --- a/flytestdlib/fastcheck/lru.go +++ b/flytestdlib/fastcheck/lru.go @@ -18,13 +18,13 @@ type LRUCacheFilter struct { } // Simply uses Contains from the LRUCacheFilter -func (l LRUCacheFilter) Contains(ctx context.Context, id []byte) bool { +func (l LRUCacheFilter) Contains(_ context.Context, id []byte) bool { v := l.lru.Contains(string(id)) if v { - l.metrics.Hit.Inc(ctx) + l.metrics.Hit.Inc() return true } - l.metrics.Miss.Inc(ctx) + l.metrics.Miss.Inc() return false } diff --git a/flytestdlib/fastcheck/oppobloom.go b/flytestdlib/fastcheck/oppobloom.go index c1ce967707..b3582fffc7 100644 --- a/flytestdlib/fastcheck/oppobloom.go +++ b/flytestdlib/fastcheck/oppobloom.go @@ -65,15 +65,15 @@ func (f *OppoBloomFilter) Add(_ context.Context, id []byte) bool { return !bytes.Equal(oldID, id) } -func (f *OppoBloomFilter) Contains(ctx context.Context, id []byte) bool { +func (f *OppoBloomFilter) Contains(_ context.Context, id []byte) bool { curr := get(f.array, f.getIndex(id)) if curr != nil { if bytes.Equal(id, *curr) { - f.metrics.Hit.Inc(ctx) + f.metrics.Hit.Inc() return true } } - f.metrics.Miss.Inc(ctx) + f.metrics.Miss.Inc() return false }