Description
I see there are already several tickets open regarding "sentry doesn't send events" but they cite different versions of the sdk and seem to be related to different causes. This may very well be a duplicate -- I'm unsure.
I've got an actix-web (3.x.x) app and I'm trying to follow along with the examples in the docs to add sentry support.
Environment
In my Cargo.toml
[dependencies.sentry]
version = "0.22.0"
features = [
"anyhow",
"log",
"debug-logs",
]
[dependencies.sentry-actix]
version = "0.22.0"
In my main.rs
:
#[actix_web::main]
async fn main() -> Result<()> {
#[cfg(feature = "dotenv")]
dotenv::dotenv().ok();
env_logger::init();
let _guard = sentry::init((
dbg!(std::env::var("SENTRY_DSN").unwrap_or_default()),
sentry::ClientOptions {
release: sentry::release_name!(),
..Default::default()
},
));
std::env::set_var("RUST_BACKTRACE", "1");
log::error!("smoke test");
// ...
log::info!("Server starting on `{}`", bind_addr);
Ok(HttpServer::new(move || {
App::new()
.wrap(middleware::Logger::default())
.wrap(sentry_actix::Sentry::new())
.configure(handlers::configure_routes)
})
.bind(bind_addr)?
.run()
.await?)
}
Steps to Reproduce
Starting the service, and making a request to a handler like:
#[get("/whoops")]
pub async fn whoops(_req: HttpRequest) -> crate::Result<&'static str> {
Err(std::io::Error::new(std::io::ErrorKind::Other, "smoke test").into())
}
Expected Result
2 new issues arriving in my sentry project
- the
log::error!("smoke test");
in main, and - the Err returned by the handler.
Actual Result
Neither issue made it through to sentry.
web | [2021-06-16T18:01:27Z DEBUG sentry::transport] spawning reqwest transport
web | [2021-06-16T18:01:27Z DEBUG sentry::init] enabled sentry client for DSN https://xxxx.sentry.io/api/0000
web | [2021-06-16T18:01:27Z ERROR chibi_cerebro] smoke test
web | [2021-06-16T18:01:27Z INFO chibi_cerebro] Server starting on `0.0.0.0:7878`
web | [2021-06-16T18:03:13Z INFO actix_web::middleware::logger] 127.0.0.1:37306 "GET /whoops HTTP/1.1" 500 36 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.101 Safari/537.36" 0.000692
web | [2021-06-16T18:03:13Z DEBUG sentry::transport] Sending envelope
web | [2021-06-16T18:03:13Z DEBUG sentry::transport] Failed to send envelope: error sending request for url (https://xxxx.sentry.io/api/0000/envelope/): error trying to connect: invalid certificate: UnknownIssuer
I notice there was no failure reported by the sentry crate for the log crate usage, so I assume the log feature just isn't working for some reason.
The request to the endpoint caused sentry to log a cert validation error.
I've additionally started to experiment with different transports to see if one might magically work as expected, but so far I've not had any luck.
For example, I get the same result with:
[dependencies.sentry]
version = "0.22.0"
default-features = false
features = [
"backtrace", "contexts", "panic",
"anyhow",
"log",
"debug-logs",
# override the default transport
"reqwest",
"rustls",
]
N.B. The docs talk about an env_logger
feature, which appears to have been removed in 0.22.0.