Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tracing): wrap error with synthetic mechanism only if attaching stacktrace #755

Merged
merged 1 commit into from
Mar 20, 2025

Conversation

lcian
Copy link
Member

@lcian lcian commented Mar 19, 2025

Description

With this change, we wrap an Error captured with e.g. tracing::error with the synthetic mechanism for tracing only if we effectively have a stack trace to be reported in the error, i.e. feature backtrace is enabled and attach_stacktrace is enabled.

Without this change, using tracing::error!(error = <err>, <message>) without the backtrace feature enabled would result in Sentry issues with <unknown> as title, as shown in #723 (comment).

Closes #723

Example

fn a() {
    let err = "NaN".parse::<u32>().unwrap_err();
    tracing::error!(error = std_dyn_err(&err), "error with error");
}

fn b() {
    let err = File::open("non_existent_file.txt").unwrap_err();
    tracing::error!(error = std_dyn_err(&err), "error with error");
}

fn c() {
    let err = File::open("non_existent_file.txt").unwrap_err();
    sentry::capture_error(&err);
}

Before

Screenshot 2025-03-19 at 17 51 22

After

Screenshot 2025-03-19 at 19 41 49

b and c will now be grouped under a single issue. This makes sense as they are carrying an equivalent Error. In absence of stack frames, we cannot distinguish between the two.
b will still include the additional message, the mechanism: tracing indicator and the Rust Tracing Context.
Screenshot 2025-03-19 at 17 41 32

While c will not include this extra info as usual.

Screenshot 2025-03-19 at 17 41 50

Copy link
Member

@Swatinem Swatinem left a comment

Choose a reason for hiding this comment

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

🎉 nice! this has bothered me for a long time for the internal symbolicator errors we have. I remember this broke at some point because of messing with these fields, and we never figured out how to fix that.

@lcian lcian merged commit e9661c7 into master Mar 20, 2025
14 checks passed
@lcian lcian deleted the lcian/fix/tracing-synthetic-only-stacktrace branch March 20, 2025 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Errors reported through sentry-tracing have unhelpful titles
2 participants