Skip to main content

ClientOptions

Struct ClientOptions 

Source
pub struct ClientOptions {
Show 30 fields pub dsn: Option<Dsn>, pub debug: bool, pub release: Option<Cow<'static, str>>, pub environment: Option<Cow<'static, str>>, pub sample_rate: f32, pub traces_sample_rate: f32, pub traces_sampler: Option<Arc<TracesSampler>>, pub max_breadcrumbs: usize, pub attach_stacktrace: bool, pub send_default_pii: bool, pub server_name: Option<Cow<'static, str>>, pub in_app_include: Vec<&'static str>, pub in_app_exclude: Vec<&'static str>, pub integrations: Vec<Arc<dyn Integration>>, pub default_integrations: bool, pub before_send: Option<BeforeCallback<Event<'static>>>, pub before_breadcrumb: Option<BeforeCallback<Breadcrumb>>, pub before_send_log: Option<BeforeCallback<Log>>, pub transport: Option<Arc<dyn TransportFactory>>, pub http_proxy: Option<Cow<'static, str>>, pub https_proxy: Option<Cow<'static, str>>, pub shutdown_timeout: Duration, pub max_request_body_size: MaxRequestBodySize, pub enable_logs: bool, pub enable_metrics: bool, pub before_send_metric: Option<BeforeCallback<Metric>>, pub accept_invalid_certs: bool, pub auto_session_tracking: bool, pub session_mode: SessionMode, pub user_agent: Cow<'static, str>,
}
Expand description

Configuration settings for the client.

These options are explained in more detail in the general sentry documentation.

§Examples

let _options = sentry::ClientOptions::new().debug(true);

Fields§

§dsn: Option<Dsn>

The DSN to use.

See dsn for details.

§debug: bool

Enables debug mode.

See debug for details.

§release: Option<Cow<'static, str>>

The release to be sent with events.

See release for details.

§environment: Option<Cow<'static, str>>

The environment to be sent with events.

See environment for details.

§sample_rate: f32

The sample rate for event submission.

See sample_rate for details.

§traces_sample_rate: f32

The sample rate for tracing transactions.

See traces_sample_rate for details.

§traces_sampler: Option<Arc<TracesSampler>>

The sampler callback for tracing transactions.

See traces_sampler for details.

§max_breadcrumbs: usize

Maximum number of breadcrumbs.

See max_breadcrumbs for details.

§attach_stacktrace: bool

Attaches stacktraces to messages.

See attach_stacktrace for details.

§send_default_pii: bool

Whether to send default PII.

See send_default_pii for details.

§server_name: Option<Cow<'static, str>>

The server name to be reported.

See server_name for details.

§in_app_include: Vec<&'static str>

Module prefixes that are always considered “in_app”.

See in_app_include for details.

§in_app_exclude: Vec<&'static str>

Module prefixes that are never “in_app”.

See in_app_exclude for details.

§integrations: Vec<Arc<dyn Integration>>

A list of integrations to enable.

See integrations and add_integration for details.

§default_integrations: bool

Whether to add default integrations.

See default_integrations for details.

§before_send: Option<BeforeCallback<Event<'static>>>

Callback that is executed before event sending.

See before_send for details.

§before_breadcrumb: Option<BeforeCallback<Breadcrumb>>

Callback that is executed for each Breadcrumb being added.

See before_breadcrumb for details.

§before_send_log: Option<BeforeCallback<Log>>

Callback that is executed for each Log being added.

See before_send_log for details.

§transport: Option<Arc<dyn TransportFactory>>

The transport to use.

See transport for details.

§http_proxy: Option<Cow<'static, str>>

An optional HTTP proxy to use.

See http_proxy for details.

§https_proxy: Option<Cow<'static, str>>

An optional HTTPS proxy to use.

See https_proxy for details.

§shutdown_timeout: Duration

The timeout on client drop for draining events on shutdown.

See shutdown_timeout for details.

§max_request_body_size: MaxRequestBodySize

The maximum size of an HTTP request body to capture.

See max_request_body_size for details.

§enable_logs: bool

Whether captured structured logs should be sent to Sentry.

See enable_logs for details.

§enable_metrics: bool

Whether metric capture APIs should capture metrics.

See enable_metrics for details.

§before_send_metric: Option<BeforeCallback<Metric>>

Callback that is executed for each Metric before sending.

See before_send_metric for details.

§accept_invalid_certs: bool

Whether to disable SSL verification.

See accept_invalid_certs for details.

§auto_session_tracking: bool

Whether Release Health Session tracking is enabled.

See auto_session_tracking for details.

§session_mode: SessionMode

Determine how Sessions are being tracked.

See session_mode for details.

§user_agent: Cow<'static, str>

The user agent that should be reported.

See user_agent for details.

Implementations§

Source§

impl ClientOptions

Source

pub fn new() -> Self

Creates new Options.

Source

pub fn dsn(self, dsn: &str) -> Self

Sets the DSN to use.

§Panics

Panics if the value fails to parse as a DSN.

Source

pub fn debug(self, debug: bool) -> Self

Enables or disables debug mode.

In debug mode debug information is printed to stderr to help you understand what sentry is doing. Defaults to false.

Source

pub fn release<T>(self, release: T) -> Self
where T: Into<Cow<'static, str>>,

Sets the release to be sent with events.

Source

pub fn maybe_release<T>(self, release: Option<T>) -> Self
where T: Into<Cow<'static, str>>,

Sets the release to be sent with events if one is provided.

Use this with release_name!, which returns the release as an Option.

Source

pub fn environment<T>(self, environment: T) -> Self
where T: Into<Cow<'static, str>>,

Sets the environment to be sent with events.

Defaults to either "development" or "production" depending on the debug_assertions cfg-attribute.

Source

pub fn sample_rate(self, sample_rate: f32) -> Self

Sets the sample rate for event submission.

Must be between 0.0 and 1.0. Defaults to 1.0.

§Panics

Panics if the sample_rate is outside the allowed range.

Source

pub fn traces_sample_rate(self, traces_sample_rate: f32) -> Self

Sets the sample rate for tracing transactions.

Must be between 0.0 and 1.0. Defaults to 0.0.

§Panics

Panics if the traces_sample_rate is outside the allowed range.

Source

pub fn traces_sampler<F>(self, traces_sampler: F) -> Self
where F: Fn(&TransactionContext) -> f32 + Send + Sync + 'static,

Sets the sampler callback for tracing transactions.

Return a sample rate between 0.0 and 1.0 for the transaction in question. Takes priority over traces_sample_rate.

Source

pub fn max_breadcrumbs(self, max_breadcrumbs: usize) -> Self

Sets the maximum number of breadcrumbs.

Defaults to 100.

Source

pub fn attach_stacktrace(self, attach_stacktrace: bool) -> Self

Enables or disables attaching stacktraces to messages.

Defaults to false.

Source

pub fn send_default_pii(self, send_default_pii: bool) -> Self

Enables or disables sending default PII.

This includes information such as potentially sensitive HTTP headers and user IP addresses in HTTP server integrations. Defaults to false.

Source

pub fn server_name<T>(self, server_name: T) -> Self
where T: Into<Cow<'static, str>>,

Sets the server name to be reported.

Source

pub fn in_app_include<I>(self, in_app_include: I) -> Self
where I: IntoIterator<Item = &'static str>,

Sets module prefixes that are always considered in-app.

Source

pub fn in_app_exclude<I>(self, in_app_exclude: I) -> Self
where I: IntoIterator<Item = &'static str>,

Sets module prefixes that are never considered in-app.

Source

pub fn integrations<I>(self, integrations: I) -> Self
where I: IntoIterator<Item = Arc<dyn Integration>>,

Sets the integrations to enable, replacing the existing list.

See sentry::integrations for how to use this to enable extra integrations. Use add_integration to append.

Source

pub fn default_integrations(self, default_integrations: bool) -> Self

Enables or disables default integrations.

See sentry::integrations for details. Defaults to true.

Source

pub fn before_send<F>(self, before_send: F) -> Self
where F: Fn(Event<'static>) -> Option<Event<'static>> + Send + Sync + 'static,

Sets the callback that is executed before event sending.

Source

pub fn before_breadcrumb<F>(self, before_breadcrumb: F) -> Self
where F: Fn(Breadcrumb) -> Option<Breadcrumb> + Send + Sync + 'static,

Sets the callback that is executed before adding each breadcrumb.

Source

pub fn before_send_log<F>(self, before_send_log: F) -> Self
where F: Fn(Log) -> Option<Log> + Send + Sync + 'static,

Sets the callback that is executed before sending each log.

Source

pub fn before_send_metric<F>(self, before_send_metric: F) -> Self
where F: Fn(Metric) -> Option<Metric> + Send + Sync + 'static,

Sets the callback that is executed before sending each metric.

This callback can modify a metric or return None to drop it.

Source

pub fn transport<T: TransportFactory + 'static>(self, transport: T) -> Self

Sets the transport to use.

This is typically either a function taking the client options by reference and returning a transport, an Arc<Transport>, or the DefaultTransportFactory. Types that do not implement TransportFactory use direct field assignment.

Source

pub fn http_proxy<T>(self, http_proxy: T) -> Self
where T: Into<Cow<'static, str>>,

Sets the optional HTTP proxy to use.

This defaults to the http_proxy environment variable.

Source

pub fn https_proxy<T>(self, https_proxy: T) -> Self
where T: Into<Cow<'static, str>>,

Sets the optional HTTPS proxy to use.

This defaults to the HTTPS_PROXY environment variable, or http_proxy if that one exists.

Source

pub fn shutdown_timeout(self, shutdown_timeout: Duration) -> Self

Sets the shutdown drain timeout.

Defaults to 2 seconds.

Source

pub fn max_request_body_size( self, max_request_body_size: MaxRequestBodySize, ) -> Self

Sets the maximum request body size to capture.

Controls the maximum size of an HTTP request body that can be captured when using HTTP server integrations. Needs send_default_pii to be enabled to have any effect. Defaults to MaxRequestBodySize::Medium.

Source

pub fn enable_logs(self, enable_logs: bool) -> Self

Enables or disables sending structured logs.

The logs feature is required to capture logs. Defaults to true.

Source

pub fn enable_metrics(self, enable_metrics: bool) -> Self

Enables or disables metric capture APIs.

The metrics feature is required to capture metrics. Defaults to true.

Source

pub fn accept_invalid_certs(self, accept_invalid_certs: bool) -> Self

Enables or disables accepting invalid TLS certificates.

This introduces significant vulnerabilities, and should only be used as a last resort. Defaults to false.

Source

pub fn auto_session_tracking(self, auto_session_tracking: bool) -> Self

Enables or disables automatic session tracking.

When enabled, a new “user-mode” session is started at sentry::init and persists for the application lifetime. Defaults to false.

Source

pub fn session_mode(self, session_mode: SessionMode) -> Self

Sets how sessions are tracked.

See SessionMode for the available modes. Defaults to SessionMode::Application.

Source

pub fn user_agent<T>(self, user_agent: T) -> Self
where T: Into<Cow<'static, str>>,

Sets the user agent that should be reported.

Defaults to the SDK user agent.

Source

pub fn add_integration<I: Integration>(self, integration: I) -> Self

Adds a configured integration to the options.

§Examples
struct MyIntegration;

impl sentry::Integration for MyIntegration {}

let options = sentry::ClientOptions::new().add_integration(MyIntegration);
assert_eq!(options.integrations.len(), 1);

Trait Implementations§

Source§

impl Clone for ClientOptions

Source§

fn clone(&self) -> ClientOptions

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ClientOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ClientOptions

Source§

fn default() -> ClientOptions

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

impl<T: IntoDsn> From<(T, ClientOptions)> for ClientOptions

Source§

fn from((into_dsn, opts): (T, ClientOptions)) -> ClientOptions

Converts to this type from the input type.
Source§

impl<T: IntoDsn> From<T> for ClientOptions

Source§

fn from(into_dsn: T) -> ClientOptions

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V