Skip to content

feat(tracing): send both breadcrumbs and logs by default #878

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Unreleased

- feat(tracing): send both breadcrumbs and logs by default ([#878](https://github.com/getsentry/sentry-rust/pull/878))
- If the `logs` feature flag is enabled, and `enable_logs: true` is set on your client options, the default Sentry `tracing` layer now sends logs for all events at or above INFO.

## 0.42.0

### Features
Expand Down
33 changes: 32 additions & 1 deletion sentry-tracing/src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ pub fn default_event_filter(metadata: &Metadata) -> EventFilter {
}
}

/// The default event filter, with logs.
///
/// By default, an exception event is captured for `error`, a breadcrumb for
/// `warning` and `info`, and `debug` and `trace` logs are ignored.
/// Additionally, a log is captured for `info`, `warning` and `error`.
pub fn default_event_filter_with_logs(metadata: &Metadata) -> EventFilter {
match metadata.level() {
&Level::ERROR => EventFilter::Event | EventFilter::Log,
&Level::WARN | &Level::INFO => EventFilter::Breadcrumb | EventFilter::Log,
&Level::DEBUG | &Level::TRACE => EventFilter::Ignore,
}
}

/// The default span filter.
///
/// By default, spans at the `error`, `warning`, and `info`
Expand Down Expand Up @@ -162,8 +175,26 @@ where
S: Subscriber + for<'a> LookupSpan<'a>,
{
fn default() -> Self {
let enable_logs = {
#[cfg(feature = "logs")]
{
sentry_core::Hub::current()
.client()
.map(|client| client.options().enable_logs)
.unwrap_or(false)
}
#[cfg(not(feature = "logs"))]
{
false
}
};

Self {
event_filter: Box::new(default_event_filter),
event_filter: Box::new(if enable_logs {
default_event_filter
} else {
default_event_filter_with_logs
}),
event_mapper: None,

span_filter: Box::new(default_span_filter),
Expand Down
Loading