-
Notifications
You must be signed in to change notification settings - Fork 108
feat(processor): Fast path rate limiting for trace attachments #5475
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 15 commits
bf8aa53
25538ec
f678302
5e277de
188c74a
4c01632
d1dfc51
6278351
9cfa3db
baeff78
f067e85
d69e169
035a5e6
4eb3517
6d493f7
38ff08c
a1fffc4
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 |
|---|---|---|
|
|
@@ -476,6 +476,27 @@ impl Item { | |
| self.is_attachment_v2() && self.parent_id().is_none() | ||
| } | ||
|
|
||
| /// Returns the [`AttachmentParentType`] of an attachment. | ||
| /// | ||
| /// For standard attachments (V1) always returns [`AttachmentParentType::Event`]. | ||
| pub fn attachment_parent_type(&self) -> AttachmentParentType { | ||
| let is_attachment = self.ty() == &ItemType::Attachment; | ||
| debug_assert!( | ||
| is_attachment, | ||
| "function should only be called on attachments" | ||
| ); | ||
| let is_trace_attachment = self.content_type() == Some(&ContentType::TraceAttachment); | ||
|
|
||
| if is_trace_attachment { | ||
| match self.parent_id() { | ||
| Some(ParentId::SpanId(_)) => AttachmentParentType::Span, | ||
| None => AttachmentParentType::Trace, | ||
| } | ||
| } else { | ||
| AttachmentParentType::Event | ||
| } | ||
| } | ||
|
|
||
| /// Returns the attachment payload size. | ||
| /// | ||
| /// For AttachmentV2, returns only the size of the actual payload, excluding the attachment meta. | ||
|
|
@@ -1086,6 +1107,23 @@ impl ParentId { | |
| } | ||
| } | ||
|
|
||
| /// The type of parent entity an attachment is associated with. | ||
|
Member
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. Would be good just to add some examples or what this is used for. |
||
| /// | ||
| /// This is used to route attachments to different rate limiting buckets, since | ||
| /// depending on the parent the limiting logic is different. E.g. if the attachment has | ||
| /// [`AttachmentParentType::Span`] than it should be dropped if there are span limits. | ||
| /// | ||
| /// See [`Item::attachment_parent_type`] for how this is determined from an item. | ||
| #[derive(Debug)] | ||
| pub enum AttachmentParentType { | ||
| /// The parent type for all V1 attachments (e.g. minidumps) | ||
| Event, | ||
| /// The parent type for all span V2 attachments. | ||
| Span, | ||
| /// The parent type for all trace V2 attachments. | ||
| Trace, | ||
|
Comment on lines
1120
to
1124
Member
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. Surprised clippy isn't mad at this, usually need to document every public symbol and enum variants are always public if the enum is. Would be good to just add documentation of what we consider an |
||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use crate::integrations::OtelFormat; | ||
|
|
||
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.
nit: I would make this an early return, i.e.