-
Notifications
You must be signed in to change notification settings - Fork 104
ref(cardinality): Recover buckets on cardinality limiter failure #2852
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ use bytes::Bytes; | |
| use chrono::{DateTime, Utc}; | ||
| use flate2::write::{GzEncoder, ZlibEncoder}; | ||
| use flate2::Compression; | ||
| use itertools::Either; | ||
| use relay_base_schema::project::{ProjectId, ProjectKey}; | ||
| use relay_common::time::UnixTimestamp; | ||
| use relay_config::{Config, HttpEncoding}; | ||
|
|
@@ -1449,21 +1450,30 @@ impl EnvelopeProcessorService { | |
| enable_cardinality_limiter: bool, | ||
| _organization_id: u64, | ||
| buckets: Vec<Bucket>, | ||
| ) -> Result<Box<dyn Iterator<Item = Bucket>>, relay_cardinality::Error> { | ||
| ) -> impl Iterator<Item = Bucket> { | ||
| if !enable_cardinality_limiter { | ||
| return Ok(Box::new(buckets.into_iter())); | ||
| // Use left for original vector of buckets, right for cardinality limited/filtered buckets. | ||
| return Either::Left(buckets.into_iter()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIUC
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exactly, but it doesn't have to be like that, |
||
| } | ||
|
|
||
| #[cfg(feature = "processing")] | ||
| if let Some(ref cardinality_limiter) = self.inner.cardinality_limiter { | ||
| return Ok(Box::new( | ||
| cardinality_limiter | ||
| .check_cardinality_limits(_organization_id, buckets)? | ||
| .into_accepted(), | ||
| )); | ||
| let limits = cardinality_limiter.check_cardinality_limits(_organization_id, buckets); | ||
|
|
||
| return match limits { | ||
| Ok(limits) => Either::Right(limits.into_accepted()), | ||
| Err((buckets, error)) => { | ||
| relay_log::error!( | ||
| error = &error as &dyn std::error::Error, | ||
| "cardinality limiter failed" | ||
| ); | ||
|
|
||
| Either::Left(buckets.into_iter()) | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| Ok(Box::new(buckets.into_iter())) | ||
| Either::<_, relay_cardinality::limiter::Accepted<_>>::Left(buckets.into_iter()) | ||
jjbayer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| fn handle_encode_metrics(&self, message: EncodeMetrics) { | ||
|
|
@@ -1476,20 +1486,11 @@ impl EnvelopeProcessorService { | |
| enable_cardinality_limiter, | ||
| } = message; | ||
|
|
||
| let buckets = match self.check_cardinality_limits( | ||
| let buckets = self.check_cardinality_limits( | ||
| enable_cardinality_limiter, | ||
| scoping.organization_id, | ||
| buckets, | ||
| ) { | ||
| Ok(buckets) => buckets, | ||
| Err(error) => { | ||
| relay_log::error!( | ||
| error = &error as &dyn std::error::Error, | ||
| "cardinality limiter failed" | ||
| ); | ||
| return; | ||
| } | ||
| }; | ||
| ); | ||
|
|
||
| let partitions = self.inner.config.metrics_partitions(); | ||
| let max_batch_size_bytes = self.inner.config.metrics_max_batch_size_bytes(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.