#with rust, is it possible to have a stack trace using tracing?

5 messages · Page 1 of 1 (latest)

spark tide
#

I'm using the tracing integration and if I do:

                capture_anyhow(&e);
                error!(
                    error = e.into_boxed_dyn_error(),
                    "error doing something"
                );

only one of the issue in sentry has a stack strace.

Is it possible to have the stack trace when using error!() since I would like the error to be loggued and not have 2 issues in sentry?

sentry-tracing seems to have some backstrace code. I wonder if the problem is caused by into_boxed_dyn_error().
https://github.com/getsentry/sentry-rust/blob/f247ac01323b093a1f7ea17abce6bc6373c68e3f/sentry-tracing/src/converters.rs#L286-L306

also it would be neat with error!() since I'm already using it everywhere.

half prawn
#

@spark tide You need to init the SDK with attach_stacktrace: true in your sentry::ClientOptions struct, then it's going to attack stacktraces to events generated from tracing events too

#

You just made me realize an issue, namely that even if you enable this option, you're going to get 2 different stacktraces in your example.
With capture_anyhow you'll get the anyhow stacktrace, while with tracing::error and co. you'll just get a stacktrace of where the call to tracing::error happened, which is way less useful.
The anyhow stacktrace will go up to the root function that first returned the error.

spark tide
#

Thanks! Shoould we make this question as resolved?