-
Notifications
You must be signed in to change notification settings - Fork 98
fix(profiling): Classify profile chunks for rate limits and outcomes #4595
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
Conversation
f6de8a0
to
65c2067
Compare
65c2067
to
d53c559
Compare
d53c559
to
4df7283
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.
Small typo, looks good otherwise
Co-authored-by: Sebastian Zivota <loewenheim@users.noreply.github.com>
pub fn profile_type(&self) -> ProfileType { | ||
match self.profile.platform.as_str() { | ||
"cocoa" | "android" | "javascript" => ProfileType::Ui, | ||
_ => ProfileType::Backend, | ||
} | ||
} |
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.
👍
/// The profile type is currently determined based on the contained profile | ||
/// platform. It determines the data category this profile chunk belongs to. | ||
/// | ||
/// This needs to be synchronized with the implementation in Sentry: |
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.
If we can add the profile_type
in the payload before we send it, this would become the source of truth.
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 we can use add it to the Kafka message https://github.com/getsentry/relay/blob/master/relay-server/src/services/store.rs#L1035-L1041 and the worker will handle it, no need to deserialize/serialize again.
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.
Sure, that works, let's figure that out in a follow up where we wanna put it (payload / kafka header) and how it should look?
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 would add it to the payload and not the header, it's easier to manipulate later on.
ItemType::ProfileChunk => match item.profile_type() { | ||
Some(ProfileType::Backend) => !self.profile_chunks.is_active(), | ||
Some(ProfileType::Ui) => !self.profile_chunks_ui.is_active(), | ||
None => true, |
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.
Will this reject or accept profiles when we don't have a type?
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.
It will accept when there is no type.
We started adding a
Platforms are not added very often, UI platforms even less often and rejecting the chunk for unknown/empty platforms is a good default. |
This separates profile chunks into two separate categories. The category is determined by the platform contained within the item payload.
This does have several downsides:
The plan is to hoist the platform into an item header, provided by the SDK directly. Once this happened we can reject all profile chunks without that necessary platform item and we can start rate limiting in the fast path.
Additionally we'll change Relay to make the executive decision whether a profile chunk is frontend/backend, this means we no longer need to make that decision in multiple places (they cannot diverge).
We will also need to consider how often the platforms change, we can extend Relay in a way where unknown platforms are just forwarded to processing but for the sake of rate limiting considered as the default category. Or just make the assignment configurable via global config.
The test
test_profile_chunk_outcomes_rate_limited_via_profile_duration_rate_limit
was never correct, the duration quota never worked it always just worked because it also contained the chunk category, but that is equivalent to the test above.Fixes: https://github.com/getsentry/team-ingest/issues/679