-
Notifications
You must be signed in to change notification settings - Fork 631
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
feat: tenant settings ruler #3944
Conversation
* metrics for exporter client * use promhttp instrumented round tripper * remove custom round tripper, add TODO
164b987
to
415f1a3
Compare
if c.value != nil && time.Now().Before(c.ttl) { | ||
// value exists and didn't expired | ||
return c.value | ||
} |
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.
I think you want to hold theRLock
for this
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.
absolutely. As this was only one file and I started from an already squashed branch to merge, I've created a new branch and PR #3945
Tenant settings ruler is a thread-safe ruler that obtains rules from tenant-settings service and caches the result for later calls.
It holds a cache for each tenant, that expires after the default time (60s).
Every first call to a tenant for
RecordingRules(tenant string)
will initialize the per-tenant cache. When calling again the method, the cached rules will be served unless they expired. In that case, cache will be refreshed.I discarded doing generics here becase (1) I would like to validate the idea and (2) there's no need to generalize the cache.