pub struct Options { /* private fields */ }
Expand description

The Sentry client options.

Examples

let _shutdown = Options::new().init()?;

Implementations

Creates new Sentry client options.

Examples
let mut options = Options::new();

Sets a custom transport. This only affects events sent through Event::capture, not the crash handler.

The startup parameter is a function that serves as a one-time initialization event for your Transport, it takes a &Options and has to return an Result<Transport, ()>, an Err will cause Options::init to fail.

Notes

Unwinding panics of functions in startup will be cought and abort will be called if any occured.

Examples
let mut options = Options::new();
options.set_transport(|_| {
    Ok(|envelope: RawEnvelope| println!("Event to be sent: {:?}", envelope.event()))
});

See Transport for a more detailed documentation.

Sets a callback that is triggered before sending an event through Event::capture.

Notes

Unwinding panics of functions in before_send will be cought and abort will be called if any occured.

Examples
let mut options = Options::new();
options.set_before_send(|mut value| {
    // do something with the value and then return it
    value
});

Sets the DSN.

Examples
let mut options = Options::new();
options.set_dsn("yourdsn.com");

Gets the DSN.

Examples
let mut options = Options::new();
options.set_dsn("yourdsn.com");

assert_eq!(Some("yourdsn.com"), options.dsn());

Sets the sample rate, which should be a f64 between 0.0 and 1.0. Sentry will randomly discard any event that is captured using Event when a sample rate < 1.0 is set.

Errors

Fails with Error::SampleRateRange if sample_rate is smaller than 0.0 or bigger than 1.0.

Examples
let mut options = Options::new();
options.set_sample_rate(0.5);

Gets the sample rate.

Examples
let mut options = Options::new();
options.set_sample_rate(0.5)?;

assert_eq!(0.5, options.sample_rate());

Sets the release.

Examples
let mut options = Options::new();
options.set_release("1.0");

Gets the release.

Examples
let mut options = Options::new();
options.set_release("1.0");

assert_eq!(Some("1.0"), options.release());

Sets the environment.

Examples
let mut options = Options::new();
options.set_environment("production");

Gets the environment.

Examples
let mut options = Options::new();
options.set_environment("production");

assert_eq!(Some("production"), options.environment());

Sets the distribution.

Examples
let mut options = Options::new();
options.set_distribution("release-pgo");

Gets the distribution.

Examples
let mut options = Options::new();
options.set_distribution("release-pgo");

assert_eq!(Some("release-pgo"), options.distribution());

Configures the http proxy.

The given proxy has to include the full scheme, eg. http://some.proxy/.

Examples
let mut options = Options::new();
options.set_http_proxy("http://some.proxy/");

Returns the configured http proxy.

Examples
let mut options = Options::new();
options.set_http_proxy("http://some.proxy/");

assert_eq!(Some("http://some.proxy/"), options.http_proxy());

Configures the path to a file containing SSL certificates for verification.

Examples
let mut options = Options::new();
options.set_ca_certs("certs.pem");

Returns the configured path for CA certificates.

Examples
let mut options = Options::new();
options.set_ca_certs("certs.pem");

assert_eq!(Some("certs.pem"), options.ca_certs());

Configures the name of the default transport thread. Has no effect when using a custom transport.

Examples
let mut options = Options::new();
options.set_transport_thread_name("sentry transport");

Returns the configured default transport thread name.

Examples
let mut options = Options::new();
options.set_transport_thread_name("sentry transport");

assert_eq!(Some("sentry transport"), options.transport_thread_name());

Enables or disables debug printing mode.

Examples
let mut options = Options::new();
options.set_debug(true);

Returns the current value of the debug flag.

Examples
let mut options = Options::new();
options.set_debug(true);

assert!(options.debug());

Sets the number of breadcrumbs being tracked and attached to events. Defaults to 100.

Examples
let mut options = Options::new();
options.set_max_breadcrumbs(10);

Gets the number of breadcrumbs being tracked and attached to events.

Examples
let mut options = Options::new();
options.set_max_breadcrumbs(10);

assert_eq!(options.max_breadcrumbs(), 10);

Sets a callback that is used for logging purposes when Options::debug is true.

Notes

Unwinding panics in logger will be cought and abort will be called if any occured.

Examples
let mut options = Options::new();
options.set_debug(true);
options.set_logger(|level, message| {
    println!("[{}]: {}", level, message);
});

Enables or disables automatic session tracking.

Automatic session tracking is enabled by default and is equivalent to calling start_session after startup. There can only be one running session, and the current session will always be closed implicitly by shutdown, when starting a new session with start_session, or manually by calling end_session.

Examples
let mut options = Options::new();
options.set_auto_session_tracking(false);
let _shutdown = options.init()?;

// code to run before starting the session

start_session();

Returns true if automatic session tracking is enabled.

Examples
let mut options = Options::new();
options.set_auto_session_tracking(false);

assert!(!options.auto_session_tracking());

Enables or disabled user consent requirements for uploads.

This disables uploads until the user has given the consent to the SDK. Consent itself is given with set_user_consent and Consent::Given or revoked with Consent::Revoked.

Examples
let mut options = Options::new();
options.set_require_user_consent(true);

Returns true if user consent is required.

Examples
let mut options = Options::new();
options.set_require_user_consent(true);

assert!(options.require_user_consent());

Enables or disables on-device symbolication of stack traces.

This feature can have a performance impact, and is enabled by default on Android. It is usually only needed when it is not possible to provide debug information files for system libraries which are needed for serverside symbolication.

Examples
let mut options = Options::new();
options.set_symbolize_stacktraces(true);

Returns true if on-device symbolication of stack traces is enabled.

Examples
let mut options = Options::new();
options.set_symbolize_stacktraces(true);

assert!(options.symbolize_stacktraces());

Adds a new attachment to be sent along.

Examples
let mut options = Options::new();
options.add_attachment("server.log");

Sets the path to the crashpad handler if the crashpad backend is used.

The path defaults to the crashpad_handler/crashpad_handler.exe executable, depending on platform, which is expected to be present in the same directory as the app executable.

It is recommended that library users set an explicit handler path, depending on the directory/executable structure of their app.

Examples
let mut options = Options::new();
options.set_handler_path("crashpad_handler");

Sets the path to the Sentry database directory.

Sentry will use this path to persist user consent, sessions, and other artifacts in case of a crash. This will also be used by the crashpad backend if it is configured.

The path defaults to .sentry-native in the current working directory, will be created if it does not exist, and will be resolved to an absolute path inside of Options::init.

It is recommended that library users set an explicit absolute path, depending on their apps runtime directory.

The directory should not be shared with other application data/configuration, as Sentry will enumerate and possibly delete files in that directory.

Examples
let mut options = Options::new();
options.set_database_path(".sentry-native");

Enables forwarding to the system crash reporter. Disabled by default.

This setting only has an effect when using Crashpad on macOS. If enabled, Crashpad forwards crashes to the macOS system crash reporter. Depending on the crash, this may impact the crash time. Even if enabled, Crashpad may choose not to forward certain crashes.

Examples
let mut options = Options::new();
options.set_system_crash_reporter(true);

Initializes the Sentry SDK with the specified options. Make sure to capture the resulting Shutdown, this makes sure to automatically call shutdown when it drops.

Errors

Fails with Error::Init if Sentry couldn’t initialize - should only occur in these situations:

  • Fails to create database directory.
  • Fails to lock database directory.
Examples
let _shutdown = Options::new().init()?;

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Executes the destructor for this type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.