Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 9 additions & 1 deletion relay-server/src/processing/spans/integrations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,15 @@ pub fn expand(
}
}

(Settings::default(), result)
let settings = Settings {
infer_ip: false,
infer_user_agent: false,
Comment on lines +54 to +55

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, do we not want to do these for OTEL spans?

infer_name: false,
// OTEL spans don't usually have a description, we want to infer it.
infer_description: true,
};

(settings, result)
}

#[derive(Debug, thiserror::Error)]
Expand Down
5 changes: 5 additions & 0 deletions relay-server/src/processing/spans/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,11 @@ struct Settings {
/// for the benefit of standalone spans which need to have a name inferred
/// after conversion to V2.
infer_name: bool,
/// Whether the description should be inferred.
///
/// This should only be enabled for V2 (and OTEL) spans sent by SDKs. V1
/// spans should already have a description.
infer_description: bool,
}

/// Spans which have been parsed and expanded from their serialized state.
Expand Down
25 changes: 20 additions & 5 deletions relay-server/src/processing/spans/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,21 @@ fn expand_span_container(item: &Item) -> Result<(Settings, ContainerItems<SpanV2
.into_parts();

relay_log::trace!("span container metadata: {metadata:?}");

// By default, we only want to infer descriptions for V2 spans.
let default_settings = Settings {
infer_description: true,
..Default::default()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not have a manual Default impl with infer_description: true? Is there a use case where we want the field to be false by default?

};

let settings = metadata
.map(|metadata| {
let is = metadata.ingest_settings.as_ref();

match metadata.version {
None => Settings::default(),
None => default_settings,
// Technically invalid.
Some(0 | 1) => Settings::default(),
Some(0 | 1) => default_settings,
Some(2) => Settings {
infer_ip: is
.and_then(|is| is.infer_ip)
Expand All @@ -116,12 +123,14 @@ fn expand_span_container(item: &Item) -> Result<(Settings, ContainerItems<SpanV2
// We don't want to infer names for V2 spans. If an SDK sent a
// V2 span without a name it's just invalid.
infer_name: false,
// We want to infer descriptions for V2 spans.
Comment thread
cursor[bot] marked this conversation as resolved.
infer_description: true,
},
// Unsupported, fall back to the safe default.
Some(_) => Default::default(),
Some(_) => default_settings,
}
})
.unwrap_or_default();
.unwrap_or(default_settings);

Ok((settings, spans))
}
Expand Down Expand Up @@ -151,6 +160,9 @@ fn expand_legacy_spans(
// The inference can't happen during the conversion
// because PII scrubbing needs to run first.
infer_name: true,
// We don't want to infer descriptions for legacy spans; they
// should already have one.
infer_description: false,
};

(settings, spans)
Expand Down Expand Up @@ -294,7 +306,10 @@ fn normalize_span_derived(
if settings.infer_name {
eap::normalize_span_name(span);
}
eap::normalize_sentry_description(&mut span.attributes, &span.name);

if settings.infer_description {
eap::normalize_sentry_description(&mut span.attributes, &span.name);
}
}

// Set a max_bytes value on the root state if it's defined in the project config.
Expand Down
Loading