Skip to main content

foundations_sentry/
lib.rs

1#![allow(clippy::needless_doctest_main, reason = "for illustration")]
2//! [`foundations`] companion crate with Sentry integrations. Includes rate limiting
3//! of sentry events and tracking them with [`foundations`] metrics.
4//!
5//! This crate provides a sentry hook that increments the
6//! `sentry_events_total{level=<...>}` metric for each sentry event. If a
7//! previous `before_send` hook exists, it will be executed after rate limiting
8//! and before the metric is incremented. Only unfiltered events are counted.
9//!
10//! For rate-limiting, we group events by fingerprint. Each group has a separate
11//! rate limiter. The fingerprint of a sentry event is the first out of the following
12//! attributes that is present and not defaulted:
13//!
14//! 1. Explicit `event.fingerprint`
15//! 2. Event message
16//! 3. First exception value, or exception type if no value is set
17//! 4. Fallback: event level name (e.g., `error`)
18//!
19//! **note**: a clone of a client's [`sentry_core::ClientOptions`] will have the
20//! hook installed. This means "child" sentry clients will inherit the hook. A
21//! reinstall is only required if the [`sentry_core::ClientOptions::before_send`]
22//! field is overwritten.
23//!
24//! # Usage
25//!
26//! To install the hook:
27//!
28//! ```rust
29//! fn main() {
30//!     let mut client_opts = sentry_core::ClientOptions::default();
31//!     let sentry_settings = foundations_sentry::SentrySettings::default();
32//!     foundations_sentry::install_hook_with_settings(&mut client_opts, &sentry_settings);
33//!     // sentry::init(client_opts);
34//! }
35//! ```
36
37pub mod metrics;
38pub mod panic;
39
40mod hook;
41mod settings;
42
43pub use self::hook::install_hook_with_settings;
44pub use self::settings::SentrySettings;