-
Notifications
You must be signed in to change notification settings - Fork 812
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove global metrics registry and global logger in cache package #2903
Remove global metrics registry and global logger in cache package #2903
Conversation
f6f4540
to
c7cd9b2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Epic job! Well done and thanks! ❤️
I left few comments, but overall the direction you're going looks good. Let's do it! 🚀
pkg/chunk/storage/factory.go
Outdated
@@ -117,19 +118,20 @@ func (cfg *Config) Validate() error { | |||
func NewStore(cfg Config, storeCfg chunk.StoreConfig, schemaCfg chunk.SchemaConfig, limits StoreLimits, reg prometheus.Registerer, cacheGenNumLoader chunk.CacheGenNumLoader) (chunk.Store, error) { | |||
chunkMetrics := newChunkClientMetrics(reg) | |||
|
|||
indexReadCache, err := cache.New(cfg.IndexQueriesCacheConfig) | |||
logger := log.NewNopLogger() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhm, no, we should pick it in input, not using the nop logger :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, yes what I am doing here is totally wrong :(.
But the logger is initialized in the service module, I need to do some work to propagate that logger here
Thanks for the review! @pracucci Is it possible to get rid of this? This relates to the counter metric here cortex/pkg/util/experimental.go Line 9 in dd23765
|
I think we wanna keep it. If the problem is the logger, you could just pass the logger to it (in callers outside the |
Signed-off-by: Ben Ye <[email protected]>
c7cd9b2
to
780e430
Compare
Signed-off-by: Ben Ye <[email protected]>
780e430
to
b64980a
Compare
Thanks. I think it is okay. Any thoughts? @bwplotka I addressed all the comments. PTAL when you get a chance 😄 @pracucci |
Signed-off-by: Ben Ye <[email protected]>
2b41b66
to
8ae218c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @yeya24 for this amazing work! LGTM 🚀 @pstibrany could take a second look, please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, it looks good from my side as well 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! While I've left some nit-picking comments, nothing that would prevent from merging.
pkg/chunk/cache/fifo_cache_test.go
Outdated
@@ -37,7 +39,7 @@ func TestFifoCacheEviction(t *testing.T) { | |||
} | |||
|
|||
for _, test := range tests { | |||
c := NewFifoCache(test.name, test.cfg) | |||
c := NewFifoCache(test.name, test.cfg, prometheus.NewRegistry(), log.NewNopLogger()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I would prefer to pass nil as registerer, if we're not testing metrics.
pkg/chunk/cache/memcached.go
Outdated
// TODO(bwplotka): Remove globals & util packages from cache package entirely (e.g util.Logger). | ||
func NewMemcached(cfg MemcachedConfig, client MemcachedClient, name string) *Memcached { | ||
func NewMemcached(cfg MemcachedConfig, client MemcachedClient, name string, reg prometheus.Registerer, logger log.Logger) *Memcached { | ||
memcacheRequestDuration := promauto.With(reg).NewHistogramVec(prometheus.HistogramOpts{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: this could be inlined.
pkg/chunk/cache/instrumented.go
Outdated
prometheus.MustRegister(hits) | ||
prometheus.MustRegister(valueSize) | ||
} | ||
requestDuration := promauto.With(reg).NewHistogramVec(prometheus.HistogramOpts{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: This can be inlined.
Signed-off-by: Ben Ye <[email protected]>
Signed-off-by: Ben Ye [email protected]
What this PR does:
This pr removes global prometheus registries and util.logger in the
cache
package. This is good for reusing this package in other project like Thanos.Which issue(s) this PR fixes:
Fixes #
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]