Skip to content

Commit 9657268

Browse files
committed
feat(quotas): Add an opportunistic cache for Quotas
1 parent 107e199 commit 9657268

File tree

12 files changed

+798
-109
lines changed

12 files changed

+798
-109
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- Add `http.request.header.cookie` to fields scrubbed by cookie rules. ([#5408](https://github.com/getsentry/relay/pull/5408))
1717
- Map `request_id` to `trace_id` in vercel log drain transform. ([#5333](https://github.com/getsentry/relay/pull/5333))
1818
- Populate `sentry.platform` during OTLP ingestion. ([#5411](https://github.com/getsentry/relay/pull/5411))
19+
- Implement optional opportunistic caching for quotas. ([#5416](https://github.com/getsentry/relay/pull/5416))
1920
- Add db attribute normalization to V2 spans. ([#5399](https://github.com/getsentry/relay/pull/5399))
2021

2122
**Internal**:

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

relay-config/src/config.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,13 @@ pub struct Processing {
11931193
/// Maximum rate limit to report to clients.
11941194
#[serde(default = "default_max_rate_limit")]
11951195
pub max_rate_limit: Option<u32>,
1196+
/// Configures the quota cache.
1197+
///
1198+
/// The quota cache, caches the specified percentage of remaining quota in memory to reduce the
1199+
/// amount of synchronizations required with Redis.
1200+
///
1201+
/// By default quota caching is disabled.
1202+
pub quota_cache_percentage: Option<f32>,
11961203
/// Configuration for attachment uploads.
11971204
#[serde(default)]
11981205
pub upload: UploadServiceConfig,
@@ -1214,6 +1221,7 @@ impl Default for Processing {
12141221
attachment_chunk_size: default_chunk_size(),
12151222
projectconfig_cache_prefix: default_projectconfig_cache_prefix(),
12161223
max_rate_limit: default_max_rate_limit(),
1224+
quota_cache_percentage: None,
12171225
upload: UploadServiceConfig::default(),
12181226
}
12191227
}
@@ -2601,6 +2609,11 @@ impl Config {
26012609
self.values.processing.max_rate_limit.map(u32::into)
26022610
}
26032611

2612+
/// Amount of remaining quota which is cached in memory.
2613+
pub fn quota_cache_percentage(&self) -> Option<f32> {
2614+
self.values.processing.quota_cache_percentage
2615+
}
2616+
26042617
/// Cache vacuum interval for the cardinality limiter in memory cache.
26052618
///
26062619
/// The cache will scan for expired values based on this interval.

relay-quotas/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ workspace = true
1919
[dependencies]
2020
async-trait = { workspace = true }
2121
hashbrown = { workspace = true }
22+
papaya = { workspace = true }
2223
itertools = { workspace = true }
2324
relay-base-schema = { workspace = true }
2425
relay-common = { workspace = true }
2526
relay-log = { workspace = true, optional = true }
2627
relay-redis = { workspace = true, optional = true }
28+
relay-statsd = { workspace = true }
2729
serde = { workspace = true }
2830
smallvec = { workspace = true }
2931
thiserror = { workspace = true, optional = true }

0 commit comments

Comments
 (0)