sentry-rust: Logs and errors are not showing up in web interface
Environment
sentry version “0.30.0” with feature “anyhow” enabled sentry-log “0.31.5”
Steps to Reproduce
early in main.rs
let logger = sentry_log::SentryLogger::with_dest(env_logger::builder().build());
log::set_boxed_logger(Box::new(logger)).unwrap();
log::set_max_level(secrets.log_level.clone().into());
let _guard = sentry::init((
"my dsn",
ClientOptions {
release: sentry::release_name!(),
environment: Some(secrets.environment.to_string().into()),
sample_rate: secrets.sentry_sample_rate.parse::<f32>().unwrap_or(0.0),
..Default::default()
},
));
in cargo.toml
sentry = { version = "0.30.0", features = ["anyhow"] }
sentry-log = "0.31.5"
using the normal log macros ( info!(), warn!(), error!() ), we’re not seeing these errors appear in sentry. Instead, we’ve been using the capture_anyhow!() macro however the insights we get aren’t the best causing debugging issues to be very slow. I’ve seen mixing documentation or lack thereof around integrations regarding this crate but nothing I’ve tried seemed to resolve this. We know errors are occurring because of logs in production. The implementation above is from the example on docs.rs, perhaps this should be updated?
Expected Result
We see errors and breadcrumbs appear in sentry when they occur.
Actual Result
Errors aren’t appearing in sentry
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 26 (13 by maintainers)
Using
#[tokio::main]may be the issue. We’re currently updating our documentation to explain why that shouldn’t be done and what to do instead. The problem is thatsentry::initmust be called before theasyncruntime is started, but#[tokio::main]prevents that.Can you rewrite main to a form like this?