Background
PR #118 left the open work to bring panic! calls outside HTTP handlers (e.g. inside start_server setup, inside a schedule {} block on a different task) into the tracing event stream. Today panics in those paths go to the default panic hook → stderr, unstructured, no tracing event with span context.
What to add
Install tracing-panic's panic hook in init_subscriber:
use tracing_panic::panic_hook;
pub fn init_subscriber() {
INIT.get_or_init(|| {
// ... existing layer setup ...
// After layer install, wrap the panic hook so panic!s become
// structured tracing::error! events.
std::panic::set_hook(Box::new(panic_hook));
});
}
~3 lines + a Cargo.toml entry. Documented on the tracing-panic README.
Origin: rust-expert review on PR #118, follow-up #3.
Background
PR #118 left the open work to bring
panic!calls outside HTTP handlers (e.g. insidestart_serversetup, inside aschedule {}block on a different task) into thetracingevent stream. Today panics in those paths go to the default panic hook → stderr, unstructured, notracingevent with span context.What to add
Install
tracing-panic's panic hook ininit_subscriber:~3 lines + a Cargo.toml entry. Documented on the
tracing-panicREADME.Origin: rust-expert review on PR #118, follow-up #3.