[][src]Trait sentry_core::Integration

pub trait Integration: Sync + Send + Any + AsAny {
    pub fn name(&self) -> &'static str { ... }
pub fn setup(&self, options: &mut ClientOptions) { ... }
pub fn process_event(
        &self,
        event: Event<'static>,
        options: &ClientOptions
    ) -> Option<Event<'static>> { ... } }

Integration abstraction.

An Integration in sentry has two primary purposes. It can act as an Event Source, which will capture new events; or as an Event Processor, which can modify every Event flowing through the pipeline.

Examples

use sentry::protocol::{Event, Level};
use sentry::ClientOptions;

struct MyProcessorIntegration {
    override_environment: &'static str,
    override_level: Level,
}

impl sentry::Integration for MyProcessorIntegration {
    fn setup(&self, options: &mut ClientOptions) {
        options.environment = Some(self.override_environment.into());
    }
    fn process_event(
        &self,
        mut event: Event<'static>,
        _options: &ClientOptions,
    ) -> Option<Event<'static>> {
        event.level = self.override_level;
        Some(event)
    }
}

let options = ClientOptions::new().add_integration(MyProcessorIntegration {
    override_environment: "my_env",
    override_level: Level::Error,
});

let events = sentry::test::with_captured_events_options(
    || {
        sentry::capture_message("some message", Level::Info);
    },
    options,
);
let captured_event = events.into_iter().next().unwrap();

assert_eq!(captured_event.level, Level::Error);
assert_eq!(captured_event.environment, Some("my_env".into()));

Provided methods

pub fn name(&self) -> &'static str[src]

Name of this integration.

This will be added to the SDK information sent to sentry.

pub fn setup(&self, options: &mut ClientOptions)[src]

Called whenever the integration is attached to a Client.

pub fn process_event(
    &self,
    event: Event<'static>,
    options: &ClientOptions
) -> Option<Event<'static>>
[src]

The Integrations Event Processor Hook.

An integration can process, or even completely drop an Event. Examples include adding or processing a backtrace, obfuscate some personal information, or add additional information.

Loading content...

Implementors

Loading content...