Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
iambriccardo committed Dec 16, 2024
1 parent a1a42b0 commit a133f4f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
11 changes: 7 additions & 4 deletions relay-server/src/services/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand Down Expand Up @@ -1886,7 +1888,7 @@ impl EnvelopeProcessorService {
#[allow(unused_variables)] sampling_project_info: Option<Arc<ProjectInfo>>,
#[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, {
Expand All @@ -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,
);
Expand Down
30 changes: 20 additions & 10 deletions relay-server/src/services/processor/span/processing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SpanGroup>,
global_config: &GlobalConfig,
config: Arc<Config>,
project_id: ProjectId,
project_info: Arc<ProjectInfo>,
sampling_project_info: Option<Arc<ProjectInfo>>,
global_config: &GlobalConfig,
geo_lookup: Option<&GeoIpLookup>,
reservoir_counters: &ReservoirEvaluator,
) {
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -266,8 +269,9 @@ fn add_sample_rate(measurements: &mut Annotated<Measurements>, name: &str, value

pub fn extract_from_event(
state: &mut ProcessEnvelopeState<TransactionGroup>,
project_info: Arc<ProjectInfo>,
global_config: &GlobalConfig,
config: Arc<Config>,
project_info: Arc<ProjectInfo>,
server_sample_rate: Option<f64>,
event_metrics_extracted: EventMetricsExtracted,
spans_extracted: SpansExtracted,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(),
};
Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -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),
Expand Down

0 comments on commit a133f4f

Please sign in to comment.