Struct sentry_contrib_native::Options[][src]

pub struct Options { /* fields omitted */ }

The Sentry client options.

Examples

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

Implementations

impl Options[src]

#[must_use = "`Options` doesn't do anything without `Options::init`"]
pub fn new() -> Self
[src]

Creates new Sentry client options.

Examples

let mut options = Options::new();

pub fn set_transport<S: FnOnce(&Self) -> Result<T, ()> + 'static + Send + Sync, T: Into<Box<T>> + Transport>(
    &mut self,
    startup: S
)
[src]

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.

pub fn set_before_send<B: Into<Box<B>> + BeforeSend>(&mut self, before_send: B)[src]

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
});

pub fn set_dsn<S: Into<String>>(&mut self, dsn: S)[src]

Sets the DSN.

Examples

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

#[must_use]
pub fn dsn(&self) -> Option<&str>
[src]

Gets the DSN.

Examples

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

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

pub fn set_sample_rate(&mut self, sample_rate: f64) -> Result<(), Error>[src]

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);

#[must_use]
pub fn sample_rate(&self) -> f64
[src]

Gets the sample rate.

Examples

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

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

pub fn set_release<S: Into<String>>(&mut self, release: S)[src]

Sets the release.

Examples

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

#[must_use]
pub fn release(&self) -> Option<&str>
[src]

Gets the release.

Examples

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

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

pub fn set_environment<S: Into<String>>(&mut self, environment: S)[src]

Sets the environment.

Examples

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

#[must_use]
pub fn environment(&self) -> Option<&str>
[src]

Gets the environment.

Examples

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

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

pub fn set_distribution<S: Into<String>>(&mut self, distribution: S)[src]

Sets the distribution.

Examples

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

#[must_use]
pub fn distribution(&self) -> Option<&str>
[src]

Gets the distribution.

Examples

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

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

pub fn set_http_proxy<S: Into<String>>(&mut self, proxy: S)[src]

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/");

#[must_use]
pub fn http_proxy(&self) -> Option<&str>
[src]

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());

pub fn set_ca_certs<S: Into<String>>(&mut self, path: S)[src]

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

Examples

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

#[must_use]
pub fn ca_certs(&self) -> Option<&str>
[src]

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());

pub fn set_debug(&mut self, debug: bool)[src]

Enables or disables debug printing mode.

Examples

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

#[must_use]
pub fn debug(&self) -> bool
[src]

Returns the current value of the debug flag.

Examples

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

assert!(options.debug());

pub fn set_max_breadcrumbs(&mut self, max_breadcrumbs: usize)[src]

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);

#[must_use]
pub fn max_breadcrumbs(&self) -> usize
[src]

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);

pub fn set_logger<L: Into<Box<L>> + Logger>(&mut self, logger: L)[src]

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);
});

pub fn set_auto_session_tracking(&mut self, val: bool)[src]

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();

#[must_use]
pub fn auto_session_tracking(&self) -> bool
[src]

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());

pub fn set_symbolize_stacktraces(&mut self, val: bool)[src]

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);

#[must_use]
pub fn symbolize_stacktraces(&self) -> bool
[src]

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());

pub fn add_attachment<P: Into<PathBuf>>(&mut self, path: P)[src]

Adds a new attachment to be sent along.

Examples

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

pub fn set_handler_path<P: Into<PathBuf>>(&mut self, path: P)[src]

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");

pub fn set_database_path<P: Into<PathBuf>>(&mut self, path: P)[src]

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");

pub fn set_system_crash_reporter(&mut self, enabled: bool)[src]

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);

pub fn init(self) -> Result<Shutdown, Error>[src]

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

impl Debug for Options[src]

impl Default for Options[src]

impl Drop for Options[src]

impl Eq for Options[src]

impl PartialEq<Options> for Options[src]

impl Send for Options[src]

impl Sync for Options[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.