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

anyhow errors are grouped incorrectly #745

Open
danechitoaie opened this issue Feb 28, 2025 · 3 comments
Open

anyhow errors are grouped incorrectly #745

danechitoaie opened this issue Feb 28, 2025 · 3 comments
Labels
area: docs Something needs to be updated in the API docs or on https://docs.sentry.io/platforms/rust

Comments

@danechitoaie
Copy link

Environment

Sentry 0.36.0

Any idea would could cause different errors logged from different parts of the app with different messages (using anyhow::anyhow!()) to be incorrectly grouped?

Image

See the above print screen.
Why is that error grouped with the others when it's different error.

One was logged with

let err_msg = "Embeddings request failed!";
let err_anyhow = anyhow::anyhow!(err_msg);
sentry::integrations::anyhow::capture_anyhow(err_anyhow);

and the other with

let err_msg = "Create thread request failed!";
let err_anyhow = anyhow::anyhow!(err_msg);
sentry::integrations::anyhow::capture_anyhow(err_anyhow);

Can this be because both errors are anyhow errors just with different messages? And somehow they have same fingerprint and Sentry groups them by that?

Would me setting a custom fingerprint help?

@lcian
Copy link
Member

lcian commented Feb 28, 2025

Hey @danechitoaie, could you try scrolling to the bottom of the issue page? There will be a section you can expand called "Event Grouping Information" which will give you more information around this.
Feel free to share it here if you need more help to understand it or if you think we might have a bug :)

@danechitoaie
Copy link
Author

Hi.
Trying to provide more details in a simplified way:

Given the following code:

    let err1 = anyhow::anyhow!("Some error!");
    sentry::integrations::anyhow::capture_anyhow(&err1);

    let err2 = anyhow::anyhow!("Other error!");
    sentry::integrations::anyhow::capture_anyhow(&err2);

In Sentry they appear like this:

Image

with the following "Event Grouping Information":

Image

So I'm not sure if this is the intended way. Basically they both are simple anyhow errors, but they are different errors generated in different place in the code, so in my opinion I think they should not be grouped.

Anyway, in my case I decided to use a custom scope.set_fingerprint(...); which now logs them separately, but I think that should be the default way... so maybe the issue/bug it's just with anyhow errors.

@lcian
Copy link
Member

lcian commented Mar 3, 2025

Thanks for adding more information @danechitoaie !

What happens here is that anyhow errors all have empty stack traces which causes them to be all grouped together as they all have the same (empty) stack trace.

I think the proper solution, which doesn't require scope.set_fingerprint, is to run the binary with RUST_BACKTRACE=1, this way anyhow will collect the backtrace which will be sent within the event by the SDK, so grouping will be correct. We should document this.
Let me know if that works!

Please note that this could possibly break your grouping for other issues as they might be reported with a different stack trace when the flag is enabled

@lcian lcian changed the title Errors are grouped incorrectly Anyhow errors are grouped incorrectly Mar 4, 2025
@lcian lcian changed the title Anyhow errors are grouped incorrectly anyhow errors are grouped incorrectly Mar 4, 2025
@lcian lcian added the area: docs Something needs to be updated in the API docs or on https://docs.sentry.io/platforms/rust label Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: docs Something needs to be updated in the API docs or on https://docs.sentry.io/platforms/rust
Projects
None yet
Development

No branches or pull requests

2 participants