Function add_breadcrumb
pub fn add_breadcrumb<B>(breadcrumb: B)where
B: IntoBreadcrumbs,
Expand description
Records a breadcrumb by calling a function.
The total number of breadcrumbs that can be recorded are limited by the
configuration on the client. This function accepts any object that
implements IntoBreadcrumbs
, which is implemented for a varienty of
common types. For efficiency reasons you can also pass a closure returning
a breadcrumb in which case the closure is only called if the client is
enabled.
The most common implementations that can be passed:
Breadcrumb
: to record a breadcrumbVec<Breadcrumb>
: to record more than one breadcrumb in one go.Option<Breadcrumb>
: to record a breadcrumb or not- additionally all of these can also be returned from an
FnOnce()
ยงExamples
use sentry::protocol::{Breadcrumb, Level, Map};
let breadcrumb = Breadcrumb {
ty: "http".into(),
category: Some("request".into()),
data: {
let mut map = Map::new();
map.insert("method".into(), "GET".into());
map.insert("url".into(), "https://example.com/".into());
map
},
..Default::default()
};
sentry::add_breadcrumb(breadcrumb.clone());
sentry::capture_message("some message", Level::Info);
assert_eq!(captured_event.breadcrumbs.values, vec![breadcrumb]);