1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//! [`foundations`] companion crate with Sentry integrations. Includes rate limiting
//! of sentry events and tracking them with [`foundations`] metrics.
//!
//! This crate provides a sentry hook that increments the
//! `sentry_events_total{level=<...>}` metric for each sentry event. If a
//! previous `before_send` hook exists, it will be executed after rate limiting
//! and before the metric is incremented. Only unfiltered events are counted.
//!
//! For rate-limiting, we group events by fingerprint. Each group has a separate
//! rate limiter. The fingerprint of a sentry event is the first out of the following
//! attributes that is present and not defaulted:
//!
//! 1. Explicit `event.fingerprint`
//! 2. Event message
//! 3. First exception value, or exception type if no value is set
//! 4. Fallback: event level name (e.g., `error`)
//!
//! **note**: a clone of a client's [`sentry_core::ClientOptions`] will have the
//! hook installed. This means "child" sentry clients will inherit the hook. A
//! reinstall is only required if the [`sentry_core::ClientOptions::before_send`]
//! field is overwritten.
//!
//! # Usage
//!
//! To install the hook:
//!
//! ```rust
//! fn main() {
//! let mut client_opts = sentry_core::ClientOptions::default();
//! let sentry_settings = foundations_sentry::SentrySettings::default();
//! foundations_sentry::install_hook_with_settings(&mut client_opts, &sentry_settings);
//! // sentry::init(client_opts);
//! }
//! ```
//!
//! # Server-side symbolication
//!
//! Stacktraces are symbolicated locally by default. To capture instruction addresses
//! without loading debug information, replace Sentry's automatic stacktrace integration
//! with [`backtrace::UnresolvedStacktraceIntegration`] and enable
//! [`panic::NoFlushPanicIntegration::with_unresolved_stacktraces`].
//!
//! Also install `sentry_debug_images::DebugImagesIntegration` (available through Sentry's
//! `debug-images` feature) to attach loaded-image addresses and build IDs. The Sentry
//! server must have access to the matching debug information, for example via debuginfod.
//! These capture integrations alone do not provide the image metadata or debug files.
//!
//! Configure the capture integrations with:
//!
//! ```rust
//! use std::sync::Arc;
//! use foundations_sentry::backtrace::UnresolvedStacktraceIntegration;
//! use foundations_sentry::panic::NoFlushPanicIntegration;
//! use sentry_core::ClientOptions;
//!
//! let options = ClientOptions {
//! attach_stacktrace: true,
//! default_integrations: false,
//! integrations: vec![
//! Arc::new(UnresolvedStacktraceIntegration),
//! Arc::new(NoFlushPanicIntegration::new().with_unresolved_stacktraces()),
//! ],
//! ..Default::default()
//! };
//! ```
//!
//! Other integrations and previously installed panic hooks can still resolve their own
//! stacktraces. Existing stacktraces on events are preserved, not replaced or resolved.
pub use install_hook_with_settings;
pub use SentrySettings;