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

fix(replays): Use different enforcement category for replay video #4459

Merged
merged 5 commits into from
Jan 21, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions relay-server/src/utils/rate_limits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ pub struct EnvelopeSummary {
/// The number of replays.
pub replay_quantity: usize,

/// The number of replay videos.
pub replay_video_quantity: usize,

/// The number of monitor check-ins.
pub monitor_quantity: usize,

Expand Down Expand Up @@ -236,7 +239,7 @@ impl EnvelopeSummary {
DataCategory::Session => &mut self.session_quantity,
DataCategory::Profile => &mut self.profile_quantity,
DataCategory::Replay => &mut self.replay_quantity,
DataCategory::ReplayVideo => &mut self.replay_quantity,
DataCategory::ReplayVideo => &mut self.replay_video_quantity,
DataCategory::Monitor => &mut self.monitor_quantity,
DataCategory::Span => &mut self.span_quantity,
DataCategory::ProfileChunk => &mut self.profile_chunk_quantity,
Expand Down Expand Up @@ -342,6 +345,8 @@ pub struct Enforcement {
pub profiles_indexed: CategoryLimit,
/// The combined replay item rate limit.
pub replays: CategoryLimit,
/// The combined replay video item rate limit.
pub replay_videos: CategoryLimit,
/// The combined check-in item rate limit.
pub check_ins: CategoryLimit,
/// The combined spans rate limit.
Expand Down Expand Up @@ -384,6 +389,7 @@ impl Enforcement {
profiles,
profiles_indexed,
replays,
replay_videos,
check_ins,
spans,
spans_indexed,
Expand All @@ -399,6 +405,7 @@ impl Enforcement {
profiles,
profiles_indexed,
replays,
replay_videos,
check_ins,
spans,
spans_indexed,
Expand Down Expand Up @@ -485,7 +492,7 @@ impl Enforcement {
ItemType::Session => !self.sessions.is_active(),
ItemType::Profile => !self.profiles_indexed.is_active(),
ItemType::ReplayEvent => !self.replays.is_active(),
ItemType::ReplayVideo => !self.replays.is_active(),
ItemType::ReplayVideo => !self.replay_videos.is_active(),
ItemType::ReplayRecording => !self.replays.is_active(),
ItemType::CheckIn => !self.check_ins.is_active(),
ItemType::Span | ItemType::OtelSpan | ItemType::OtelTracesData => {
Expand Down Expand Up @@ -757,6 +764,21 @@ where
rate_limits.merge(replay_limits);
}

// Handle replay video.
// Remove: 2025-04-06
if summary.replay_video_quantity > 0 {
let item_scoping = scoping.item(DataCategory::ReplayVideo);
let replay_limits = self
.check
.apply(item_scoping, summary.replay_video_quantity)?;
enforcement.replays = CategoryLimit::new(
DataCategory::ReplayVideo,
summary.replay_video_quantity,
replay_limits.longest(),
);
rate_limits.merge(replay_limits);
}

// Handle monitor checkins.
if summary.monitor_quantity > 0 {
let item_scoping = scoping.item(DataCategory::Monitor);
Expand Down
Loading