@@ -100,8 +100,8 @@ pub struct ProjectConfig {
100100
101101impl ProjectConfig {
102102 /// Validates fields in this project config and removes values that are partially invalid.
103- pub fn sanitize ( & mut self ) {
104- self . remove_invalid_quotas ( ) ;
103+ pub fn sanitize ( & mut self , report_errors : bool ) {
104+ self . remove_invalid_quotas ( report_errors ) ;
105105
106106 metrics:: convert_conditional_tagging ( self ) ;
107107 defaults:: add_span_metrics ( self ) ;
@@ -113,34 +113,37 @@ impl ProjectConfig {
113113 for flag in GRADUATED_FEATURE_FLAGS {
114114 self . features . 0 . insert ( * flag) ;
115115 }
116+ }
116117
117- // Check if indexed and non-indexed are double-counting towards the same ID.
118- // This is probably not intended behavior.
119- for quota in & self . quotas {
120- if let Some ( id) = quota. id . as_deref ( ) {
121- for category in & * quota. categories {
122- if let Some ( indexed) = category. index_category ( )
123- && quota. categories . contains ( & indexed)
124- {
125- relay_log:: error!(
126- tags. id = id,
127- "Categories {category} and {indexed} share the same quota ID. This will double-count items." ,
128- ) ;
118+ fn remove_invalid_quotas ( & mut self , report_errors : bool ) {
119+ let invalid_quotas: Vec < _ > = self . quotas . extract_if ( .., |q| !q. is_valid ( ) ) . collect ( ) ;
120+ if report_errors {
121+ if !invalid_quotas. is_empty ( ) {
122+ {
123+ relay_log:: warn!(
124+ invalid_quotas = ?invalid_quotas,
125+ "Found an invalid quota definition" ,
126+ ) ;
127+ }
128+ }
129+ // Check if indexed and non-indexed are double-counting towards the same ID.
130+ // This is probably not intended behavior.
131+ for quota in & self . quotas {
132+ if let Some ( id) = quota. id . as_deref ( ) {
133+ for category in & * quota. categories {
134+ if let Some ( indexed) = category. index_category ( )
135+ && quota. categories . contains ( & indexed)
136+ {
137+ relay_log:: error!(
138+ tags. id = id,
139+ "Categories {category} and {indexed} share the same quota ID. This will double-count items." ,
140+ ) ;
141+ }
129142 }
130143 }
131144 }
132145 }
133146 }
134-
135- fn remove_invalid_quotas ( & mut self ) {
136- let invalid_quotas: Vec < _ > = self . quotas . extract_if ( .., |q| !q. is_valid ( ) ) . collect ( ) ;
137- if !invalid_quotas. is_empty ( ) {
138- relay_log:: warn!(
139- invalid_quotas = ?invalid_quotas,
140- "Found an invalid quota definition" ,
141- ) ;
142- }
143- }
144147}
145148
146149impl Default for ProjectConfig {
@@ -284,7 +287,7 @@ mod tests {
284287 fn graduated_feature_flag_gets_inserted ( ) {
285288 let mut project_config = ProjectConfig :: default ( ) ;
286289 assert ! ( !project_config. features. has( Feature :: UserReportV2Ingest ) ) ;
287- project_config. sanitize ( ) ;
290+ project_config. sanitize ( false ) ;
288291 assert ! ( project_config. features. has( Feature :: UserReportV2Ingest ) ) ;
289292 }
290293}
0 commit comments