From aae9aeff4338e82a71d88178c3a6e2692a5951a1 Mon Sep 17 00:00:00 2001 From: Madhuri Kadam Date: Thu, 29 Feb 2024 10:21:53 +0530 Subject: [PATCH 1/2] Add Register metrics --- entity_cache.go | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/entity_cache.go b/entity_cache.go index d8d209d..a70574a 100644 --- a/entity_cache.go +++ b/entity_cache.go @@ -40,18 +40,19 @@ func New( if err != nil { return nil, err } + pr := prometheus.NewCounterVec( + prometheus.CounterOpts{ + Name: promMetricName, + Help: "A counter of hit/miss on the entity cache.", + }, + []string{"namespace", "hit"}, + ) + prometheus.MustRegister(pr) return &EntityCache{ - promHitCounter: prometheus.NewCounterVec( - prometheus.CounterOpts{ - Name: promMetricName, - Help: "A counter of hit/miss on the entity cache.", - }, - []string{"namespace", "hit"}, - ), - - maxEntries: maxEntries, - ttr: ttr, - ttl: ttl, + promHitCounter: pr, + maxEntries: maxEntries, + ttr: ttr, + ttl: ttl, cache: cache, locker: locker.NewEntityLocker(), From 0b02bf3d7b65f3993cc753eb66d2370b6c270f40 Mon Sep 17 00:00:00 2001 From: Madhuri Kadam Date: Thu, 29 Feb 2024 10:40:18 +0530 Subject: [PATCH 2/2] Update the go mod --- go.mod | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 126b29a..49473ec 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/solher/entitycache +module github.com/justwatch/entitycache go 1.21.0 @@ -22,3 +22,5 @@ require ( golang.org/x/sys v0.8.0 // indirect google.golang.org/protobuf v1.30.0 // indirect ) + +replace github.com/solher/entitycache => github.com/justwatch/entitycache v0.0.0-20240229045341-55dfa11564a7