Skip to content

feat(tracing): support combined EventFilters and EventMappings #847

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 2 commits into
base: master
Choose a base branch
from

Conversation

lcian
Copy link
Member

@lcian lcian commented Jun 18, 2025

It seems common enough that someone would want to want to map a tracing event to multiple item types, and right now that's not possible, you have to choose between Ignore/Event/Breadcrumb/Log.
For example, in Relay we want to send everything at or above INFO level to logs, while still sending ERROR events to Sentry events at the same time.

This is a proposal for how to implement that.
This particular solution requires 2 breaking changes, even though both could be avoided.
I would argue that they are not actually breaking for most users though, i.e. those that just set up a custom filter, as this is still backwards compatible in terms of syntax, even though the underlying type changes.

Copy link

Fails
🚫 Please consider adding a changelog entry for the next release.
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

- support combined EventFilters and EventMappings ([#847](https://github.com/getsentry/sentry-rust/pull/847))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description.

Generated by 🚫 dangerJS against 49f7273

@@ -182,7 +182,7 @@ impl Visit for FieldVisitor {
/// Creates a [`Breadcrumb`] from a given [`tracing_core::Event`].
pub fn breadcrumb_from_event<'context, S>(
event: &tracing_core::Event,
ctx: impl Into<Option<Context<'context, S>>>,
ctx: impl Into<Option<&'context Context<'context, S>>>,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking change here and in the 2 functions below.
This could be avoided by cloning the Context in on_event.

Copy link

codecov bot commented Jun 18, 2025

Codecov Report

Attention: Patch coverage is 95.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 74.23%. Comparing base (333b14e) to head (49f7273).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #847      +/-   ##
==========================================
+ Coverage   74.05%   74.23%   +0.18%     
==========================================
  Files          64       64              
  Lines        7781     7805      +24     
==========================================
+ Hits         5762     5794      +32     
+ Misses       2019     2011       -8     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

/// Create a [`sentry_core::protocol::Log`] from this [`Event`]
#[cfg(feature = "logs")]
Log,
bitflags! {
Copy link
Member Author

@lcian lcian Jun 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking change because we switch from enum to struct.
This could be avoided by adding a Combined enum variant and possibly implementing BitOr on EventFilter if we want the same syntax that bitflags offers.

match item {
EventMapping::Event(event) => {
sentry_core::capture_event(event);
let items = CombinedEventMapping::from(items);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I convert to CombinedEventMapping here so that below I can just handle it with the for loop instead of handling single and combined separately.

@lcian lcian requested a review from Swatinem June 18, 2025 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants