Skip to content
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

Closed
wants to merge 24 commits into from
Closed

Conversation

alsoba13
Copy link
Contributor

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.

@alsoba13 alsoba13 force-pushed the alsoba13/tenant-settings-ruler branch from 164b987 to 415f1a3 Compare February 24, 2025 16:02
Base automatically changed from alsoba13/metrics-from-profiles-record-and-export to main February 24, 2025 16:16
Comment on lines +113 to +116
if c.value != nil && time.Now().Before(c.ttl) {
// value exists and didn't expired
return c.value
}
Copy link
Contributor

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

Copy link
Contributor Author

@alsoba13 alsoba13 Feb 24, 2025

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

@alsoba13 alsoba13 closed this Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants