[][src]Function sentry::init

pub fn init<C>(opts: C) -> ClientInitGuard where
    C: Into<ClientOptions>, 

Creates the Sentry client for a given client config and binds it.

This returns a client init guard that must kept in scope will help the client send events before the application closes. When the guard is dropped then the transport that was initialized shuts down and no further events can be sent on it.

If you don't want (or can) keep the guard around it's permissible to call mem::forget on it.


let _sentry = sentry::init("https://key@sentry.io/1234");

Or if draining on shutdown should be ignored: This is not recommended, as events or session updates that have been queued might be lost.


The guard returned can also be inspected to see if a client has been created to enable further configuration:

let sentry = sentry::init(sentry::ClientOptions {
    release: Some("foo-bar-baz@1.0.0".into()),
if sentry.is_enabled() {
    // some other initialization

This behaves similar to creating a client by calling Client::from_config and to then bind it to the hub except it also applies default integrations, a default transport, as well as other options populated from environment variables. For more information about the formats accepted see Client::from_config, and ClientOptions.


This will panic when the provided DSN is invalid. If you want to handle invalid DSNs you need to parse them manually by calling parse on it and handle the error.