sentry-rust icon indicating copy to clipboard operation
sentry-rust copied to clipboard

Switch to `PanicHookInfo` in `sentry-panic`

Open lcian opened this issue 6 months ago • 3 comments

Description

The MSRV for this crate is 1.81, we should use PanicHookInfo instead of PanicInfo which is deprecated.

lcian avatar Jul 08 '25 12:07 lcian

Also check if there's anything else deprecated that we're using that we could switch from.

lcian avatar Jul 08 '25 12:07 lcian

Given that you setup panic hooks. Is it safe to drop ClientInitGuard at runtime in order to disable Sentry and then initialize a new instance of Sentry later on to re-enable it? Asking because I'd like to find a way to enable/disable Sentry dynamically without restarting the process. I am not certain that this is handled gracefully wrt panic hook especially if something else in the app wraps the installed panic hook.

pronebird avatar Jul 26 '25 10:07 pronebird

Hi @pronebird, yeah that's safe to do. What happens if you drop the client init guard is that the panic hook will remain installed, but will effectively be a no-op if a panic happens. Then when you reinitialize, a client will be active and so the panic will be captured. Of course this works if your app properly wraps the panic hook from Sentry instead of completely replacing it.

lcian avatar Jul 28 '25 09:07 lcian