@@ -14,6 +14,7 @@ pub struct RateLimiter {
1414 transaction : Option < SystemTime > ,
1515 attachment : Option < SystemTime > ,
1616 log_item : Option < SystemTime > ,
17+ trace_metric : Option < SystemTime > ,
1718}
1819
1920impl RateLimiter {
@@ -59,6 +60,7 @@ impl RateLimiter {
5960 "transaction" => self . transaction = new_time,
6061 "attachment" => self . attachment = new_time,
6162 "log_item" => self . log_item = new_time,
63+ "trace_metric" => self . trace_metric = new_time,
6264 _ => { }
6365 }
6466 }
@@ -93,6 +95,7 @@ impl RateLimiter {
9395 RateLimitingCategory :: Transaction => self . transaction ,
9496 RateLimitingCategory :: Attachment => self . attachment ,
9597 RateLimitingCategory :: LogItem => self . log_item ,
98+ RateLimitingCategory :: TraceMetric => self . trace_metric ,
9699 } ?;
97100 time_left. duration_since ( SystemTime :: now ( ) ) . ok ( )
98101 }
@@ -119,6 +122,9 @@ impl RateLimiter {
119122 EnvelopeItem :: ItemContainer ( ItemContainer :: Logs ( _) ) => {
120123 RateLimitingCategory :: LogItem
121124 }
125+ EnvelopeItem :: ItemContainer ( ItemContainer :: TraceMetrics ( _) ) => {
126+ RateLimitingCategory :: TraceMetric
127+ }
122128 _ => RateLimitingCategory :: Any ,
123129 } )
124130 } )
@@ -140,6 +146,8 @@ pub enum RateLimitingCategory {
140146 Attachment ,
141147 /// Rate Limit pertaining to Log Items.
142148 LogItem ,
149+ /// Rate Limit pertaining to Trace Metrics.
150+ TraceMetric ,
143151}
144152
145153#[ cfg( test) ]
@@ -155,6 +163,7 @@ mod tests {
155163 assert ! ( rl. is_disabled( RateLimitingCategory :: Session ) . unwrap( ) <= Duration :: from_secs( 60 ) ) ;
156164 assert ! ( rl. is_disabled( RateLimitingCategory :: Transaction ) . is_none( ) ) ;
157165 assert ! ( rl. is_disabled( RateLimitingCategory :: LogItem ) . is_none( ) ) ;
166+ assert ! ( rl. is_disabled( RateLimitingCategory :: TraceMetric ) . is_none( ) ) ;
158167 assert ! ( rl. is_disabled( RateLimitingCategory :: Any ) . is_none( ) ) ;
159168
160169 rl. update_from_sentry_header (
@@ -185,6 +194,9 @@ mod tests {
185194 assert ! (
186195 rl. is_disabled( RateLimitingCategory :: Attachment ) . unwrap( ) <= Duration :: from_secs( 120 )
187196 ) ;
197+ assert ! (
198+ rl. is_disabled( RateLimitingCategory :: TraceMetric ) . unwrap( ) <= Duration :: from_secs( 120 )
199+ ) ;
188200 assert ! ( rl. is_disabled( RateLimitingCategory :: Any ) . unwrap( ) <= Duration :: from_secs( 120 ) ) ;
189201 }
190202
0 commit comments