Skip to content
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

Add ignoreTransactions and ignoreErrors #2306

Open
3 tasks
Tracked by #108 ...
smeubank opened this issue Apr 17, 2023 · 7 comments
Open
3 tasks
Tracked by #108 ...

Add ignoreTransactions and ignoreErrors #2306

smeubank opened this issue Apr 17, 2023 · 7 comments
Labels
Feature New feature or request Good First Issue Good for newcomers

Comments

@smeubank
Copy link
Member

smeubank commented Apr 17, 2023

Background:

To further simplfiy ignoring certain events from being sent to sentry, it is also suggested to provide ignoreTransactions and ignoreErrors

More info here develop docs updated: https://develop.sentry.dev/sdk/features/#event-sampling

  • ignoreErrors
  • ignoreTransactions
  • SDK docs
@smeubank smeubank changed the title dotnet - Add ignoreTransactions and ignoreErrors Apr 17, 2023
@smeubank smeubank transferred this issue from getsentry/team-webplatform-meta Apr 17, 2023
@smeubank smeubank added the Feature New feature or request label Apr 17, 2023
@mattjohnsonpint
Copy link
Contributor

For ignoreErrors, the .NET SDK already has exception filters, which I believe is the same concept.

Examples:

SentrySdk.Init(options =>
{
    options.AddExceptionFilterForType<FileNotFoundException>();
});

Or:

SentrySdk.Init(options =>
{
    options.AddExceptionFilter(new MyExceptionFilter());
});

public class MyExceptionFilter : IExceptionFilter
{
    public bool Filter(Exception ex) => ex.Message.Contains("something");
}

We could add another IgnoreErrors property, but I'm not sure that it would add any additional value. Comparing with other SDKs:

  • Java has ignoredExceptionsForType, which would be like calling our AddExceptionFilter multiple times.
  • JavaScript has ignoreErrors that takes an array of strings or regex to match against the message. This might be confusing in .NET because we would usually want a strong match by the type, rather than a substring of the message. (Especially since message strings are often translated for localization.)

@mattjohnsonpint
Copy link
Contributor

We don't have any ignoreTransactions equivalent though (other than filtering them out in BeforeSendTransaction). I presume it should be similar to the JavaScript version.

@bitsandfoxes
Copy link
Contributor

The SDK functionally supports these via

@ericsampson
Copy link

It feels like in the docs, AddExceptionFilterForType should be mentioned in the Filtering section. Right now it's in an an odd place in the docs

@bitsandfoxes
Copy link
Contributor

It feels like in the docs, AddExceptionFilterForType should be mentioned in the Filtering section. Right now it's in an an odd place in the docs

Good callout! Thanks!

@ericsampson
Copy link

This could be a dumb question, but does that exception filter affect Transactions in any way, or just Errors?

@jamescrosswell
Copy link
Collaborator

does that exception filter affect Transactions in any way, or just Errors?

Just error events:

var filteredExceptions = ApplyExceptionFilters(@event.Exception);
if (filteredExceptions?.Count > 0)
{
_options.ClientReportRecorder.RecordDiscardedEvent(DiscardReason.EventProcessor, DataCategory.Error);
_options.LogInfo("Event was dropped by one or more exception filters for exception(s): {0}",
string.Join(", ", filteredExceptions.Select(e => e.GetType()).Distinct()));
return SentryId.Empty;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature or request Good First Issue Good for newcomers
Projects
Status: No status
Status: No status
Archived in project
Development

No branches or pull requests

5 participants