Skip to main content

health/
health.rs

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