abhinavrathore019
abhinavrathore019

Reputation: 6635

sentry-rust init stops working when extracted out to a separate function?

This works

fn main() {
    init_instrumentation();
}

fn init_instrumentation() {
    let sentry_options = sentry::ClientOptions {
        release: sentry::release_name!(),
        environment: Some(env_name.into()),
        ..Default::default()
    };
    let _guard = sentry::init((sentry_endpoint, sentry_options));
 sentry::capture_message("Hello world", sentry::Level::Info);
}

This does not

fn main() {
    init_instrumentation();
    sentry::capture_message("Hello world", sentry::Level::Info);
}

fn init_instrumentation() {
    let sentry_options = sentry::ClientOptions {
        release: sentry::release_name!(),
        environment: Some(env_name.into()),
        ..Default::default()
    };
    let _guard = sentry::init((sentry_endpoint, sentry_options));
}

Not able to understand why extracting out the init to separate function stops working. I have tried adding std::thread::sleep(std::time::Duration::from_secs(10)); before capturing the message in-case initialization is taking time.

Upvotes: 0

Views: 22

Answers (0)

Related Questions