Skip to content
Merged
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
15 changes: 15 additions & 0 deletions sentry-tracing/src/converters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ where
match &span_data.sentry_span {
TransactionOrSpan::Span(span) => {
for (key, value) in span.data().iter() {
if is_sentry_span_attribute(key) {
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible that a user would set a Sentry span attribute manually, and would we want to keep that attribute in that case?

Copy link
Member

Choose a reason for hiding this comment

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

l: also I would suggest using a .filter on the iterator, rather than the if block with a continue. Imo iterator chains tend to be more readable than branching via if statements

Copy link
Member Author

@lcian lcian Sep 22, 2025

Choose a reason for hiding this comment

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

Unlikely, but in theory it's possible that you could want to override them yeah.

continue;
}
if key != "message" {
let key = format!("{name}:{key}");
visitor.json_values.insert(key, value.clone());
Expand All @@ -109,6 +112,9 @@ where
}
TransactionOrSpan::Transaction(transaction) => {
for (key, value) in transaction.data().iter() {
if is_sentry_span_attribute(key) {
continue;
}
if key != "message" {
let key = format!("{name}:{key}");
visitor.json_values.insert(key, value.clone());
Expand All @@ -123,6 +129,15 @@ where
(message, visitor)
}

/// Checks whether the given attribute name is one of those set on a span by the Sentry layer.
/// In that case, we want to skip materializing it when propagating attributes, as it would mostly create noise.
fn is_sentry_span_attribute(name: &str) -> bool {
matches!(
name,
"sentry.tracing.target" | "code.module.name" | "code.file.path" | "code.line.number"
)
}

/// Records the fields of a [`tracing_core::Event`].
#[derive(Default)]
pub(crate) struct FieldVisitor {
Expand Down
Loading