From a133f4f0af5692ba0e9d21b030daec8c0d4c65c1 Mon Sep 17 00:00:00 2001 From: Riccardo Busetti Date: Mon, 16 Dec 2024 16:13:24 +0100 Subject: [PATCH] Fix --- relay-server/src/services/processor.rs | 11 ++++--- .../src/services/processor/span/processing.rs | 30 ++++++++++++------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/relay-server/src/services/processor.rs b/relay-server/src/services/processor.rs index 1f84ef58b8..72b83ee1a2 100644 --- a/relay-server/src/services/processor.rs +++ b/relay-server/src/services/processor.rs @@ -1720,7 +1720,8 @@ impl EnvelopeProcessorService { if_processing!(self.inner.config, { // Process profiles before extracting metrics, to make sure they are removed if they are invalid. - let profile_id = profile::process(state, &global_config, config, project_info.clone()); + let profile_id = + profile::process(state, &global_config, config.clone(), project_info.clone()); profile::transfer_id(state, profile_id); // Always extract metrics in processing Relays for sampled items. @@ -1736,8 +1737,9 @@ impl EnvelopeProcessorService { if project_info.has_feature(Feature::ExtractSpansFromEvent) { spans_extracted = span::extract_from_event( state, - project_info.clone(), &global_config, + config, + project_info.clone(), server_sample_rate, event_metrics_extracted, spans_extracted, @@ -1886,7 +1888,7 @@ impl EnvelopeProcessorService { #[allow(unused_variables)] sampling_project_info: Option>, #[allow(unused_variables)] reservoir_counters: ReservoirCounters, ) -> Result<(), ProcessingError> { - span::filter(state, config, project_info.clone()); + span::filter(state, config.clone(), project_info.clone()); span::convert_otel_traces_data(state); if_processing!(self.inner.config, { @@ -1898,10 +1900,11 @@ impl EnvelopeProcessorService { span::process( state, + &global_config, + config, project_id, project_info.clone(), sampling_project_info, - &global_config, self.inner.geoip_lookup.as_ref(), &reservoir, ); diff --git a/relay-server/src/services/processor/span/processing.rs b/relay-server/src/services/processor/span/processing.rs index db78c2ef52..5286445f4f 100644 --- a/relay-server/src/services/processor/span/processing.rs +++ b/relay-server/src/services/processor/span/processing.rs @@ -45,12 +45,14 @@ use thiserror::Error; #[error(transparent)] struct ValidationError(#[from] anyhow::Error); +#[allow(clippy::too_many_arguments)] pub fn process( state: &mut ProcessEnvelopeState, + global_config: &GlobalConfig, + config: Arc, project_id: ProjectId, project_info: Arc, sampling_project_info: Option>, - global_config: &GlobalConfig, geo_lookup: Option<&GeoIpLookup>, reservoir_counters: &ReservoirEvaluator, ) { @@ -60,6 +62,7 @@ pub fn process( // once for all spans in the envelope. let sampling_result = dynamic_sampling::run( state, + config.clone(), project_info.clone(), sampling_project_info, reservoir_counters, @@ -70,7 +73,7 @@ pub fn process( _ => None, }; let normalize_span_config = NormalizeSpanConfig::new( - &state.config, + &config, global_config, project_info.config(), &state.managed_envelope, @@ -266,8 +269,9 @@ fn add_sample_rate(measurements: &mut Annotated, name: &str, value pub fn extract_from_event( state: &mut ProcessEnvelopeState, - project_info: Arc, global_config: &GlobalConfig, + config: Arc, + project_info: Arc, server_sample_rate: Option, event_metrics_extracted: EventMetricsExtracted, spans_extracted: SpansExtracted, @@ -356,8 +360,7 @@ pub fn extract_from_event( let Some(transaction_span) = extract_transaction_span( event, - state - .config + config .aggregator_config_for(MetricNamespace::Spans) .aggregator .max_tag_value_length, @@ -865,7 +868,6 @@ mod tests { event: Annotated::from(event), metrics: Default::default(), extracted_metrics: ProcessingExtractedMetrics::new(), - config: Arc::new(Config::default()), rate_limits: Arc::new(RateLimits::default()), managed_envelope: managed_envelope.try_into().unwrap(), }; @@ -876,12 +878,14 @@ mod tests { #[test] fn extract_sampled_default() { let global_config = GlobalConfig::default(); + let config = Arc::new(Config::default()); assert!(global_config.options.span_extraction_sample_rate.is_none()); let (mut state, project_info) = state(); extract_from_event( &mut state, - project_info, &global_config, + config, + project_info, None, EventMetricsExtracted(false), SpansExtracted(false), @@ -900,11 +904,13 @@ mod tests { fn extract_sampled_explicit() { let mut global_config = GlobalConfig::default(); global_config.options.span_extraction_sample_rate = Some(1.0); + let config = Arc::new(Config::default()); let (mut state, project_info) = state(); extract_from_event( &mut state, - project_info, &global_config, + config, + project_info, None, EventMetricsExtracted(false), SpansExtracted(false), @@ -923,11 +929,13 @@ mod tests { fn extract_sampled_dropped() { let mut global_config = GlobalConfig::default(); global_config.options.span_extraction_sample_rate = Some(0.0); + let config = Arc::new(Config::default()); let (mut state, project_info) = state(); extract_from_event( &mut state, - project_info, &global_config, + config, + project_info, None, EventMetricsExtracted(false), SpansExtracted(false), @@ -946,11 +954,13 @@ mod tests { fn extract_sample_rates() { let mut global_config = GlobalConfig::default(); global_config.options.span_extraction_sample_rate = Some(1.0); // force enable + let config = Arc::new(Config::default()); let (mut state, project_info) = state(); // client sample rate is 0.2 extract_from_event( &mut state, - project_info, &global_config, + config, + project_info, Some(0.1), EventMetricsExtracted(false), SpansExtracted(false),