Skip to main content

health/
health.rs

1#![expect(missing_docs, reason = "predates lint enforcement")]
2
3fn main() {
4    let _sentry = sentry::init(
5        sentry::ClientOptions::new()
6            // release health requires a release to be set
7            .maybe_release(sentry::release_name!())
8            .debug(true)
9            // session tracking is enabled by default, but we want to explicitly
10            // create the session
11            .auto_session_tracking(false),
12    );
13
14    let handle = std::thread::spawn(|| {
15        // this session will be set to crashed
16        sentry::start_session();
17        std::thread::sleep(std::time::Duration::from_secs(3));
18        panic!("oh no!");
19    });
20
21    sentry::start_session();
22
23    sentry::capture_message(
24        "anything with a level >= Error will increase the error count",
25        sentry::Level::Error,
26    );
27
28    // or any error that has an explicit exception attached
29    let err = "NaN".parse::<usize>().unwrap_err();
30    sentry::capture_error(&err);
31
32    std::thread::sleep(std::time::Duration::from_secs(2));
33
34    // this session will have an error count of 2, but otherwise have
35    // a clean exit.
36    sentry::end_session();
37
38    handle.join().ok();
39}