getsentry/sentry-rust

tracing: Propagate span to tags

frjonsen opened this issue · 2 comments

This is related to what was solved in this PR: #629

Currently all spans are propagated to context. I feel what's missing is that spans named "tags" should instead be propagated to tags in Sentry.

At a glance it should be sufficient to add a check in the arms of this match

match &span_data.sentry_span {
TransactionOrSpan::Span(span) => {
for (key, value) in span.data().iter() {
if key != "message" {
let key = format!("{}:{}", name, key);
visitor.json_values.insert(key, value.clone());
}
}
}
TransactionOrSpan::Transaction(transaction) => {
for (key, value) in transaction.data().iter() {
if key != "message" {
let key = format!("{}:{}", name, key);
visitor.json_values.insert(key, value.clone());
}
}
}
}
where if the span name is tags, then the key should be formatted as tags.{}, rather than the current {}.{}.

TBH, this feels a bit too magical, and might lead to some surprises as well.

Especially if you happen to have such a function:

#[tracing::instrument]
fn tags(arg: ()) {
}

This is an interesting idea though, and may be something to put more thought into.

Closing per @Swatinem's comment