Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feat: Add IgnoreTransactions option to filter transactions by name - #5377

#5377
Merged
jamescrosswell merged 6 commits into
getsentry:maingetsentry/sentry-dotnet:mainfrom
Adham-Kiwan:feat/ignore-transactionsAdham-Kiwan/sentry-dotnet:feat/ignore-transactionsCopy head branch name to clipboard
Jul 13, 2026
Merged

feat: Add IgnoreTransactions option to filter transactions by name#5377
jamescrosswell merged 6 commits into
getsentry:maingetsentry/sentry-dotnet:mainfrom
Adham-Kiwan:feat/ignore-transactionsAdham-Kiwan/sentry-dotnet:feat/ignore-transactionsCopy head branch name to clipboard

Conversation

@Adham-Kiwan

@Adham-Kiwan Adham-Kiwan commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a first-class SentryOptions.IgnoreTransactions option: a list of substrings or regular expressions. A transaction whose name matches any entry is dropped before it is sent, mirroring ignoreTransactions in the JavaScript and Python SDKs.

Previously this required writing a BeforeSendTransaction callback (as noted by the maintainers in the issue). The new option gives parity with the other SDKs and the same shape as the existing TagFilters / TracePropagationTargets options.

Fixes #2306

(The ignoreErrors half of that issue is intentionally out of scope — it was marked "won't do" there, since exception filters already cover it.)

Changelog Entry

Add IgnoreTransactions option to filter out transactions by name, matching substrings or regular expressions against the transaction name (#5377)

Implementation

  • SentryOptions.IgnoreTransactionsIList<StringOrRegex>, defaulting to empty (opt-in), matching the TagFilters pattern.
  • SentryClient.CaptureTransaction — drops a transaction whose Name matches, using the existing MatchesSubstringOrRegex helper, right after the required-field validation and before BeforeSendTransaction. Discards are recorded against the client report recorder (DiscardReason.EventProcessor)
  • BindableSentryOptions — added the List<string>? surrogate + ApplyTo mapping for AOT-safe configuration binding, as required by the BindableProperties_MatchOptionsProperties guard.

Adds a first-class `SentryOptions.IgnoreTransactions` option, a list of
substrings or regular expressions. A transaction whose name matches any
entry is dropped in `SentryClient.CaptureTransaction` before the
BeforeSendTransaction callback, mirroring the `ignoreTransactions`
option in the JavaScript and Python SDKs.

Previously this could only be achieved by writing a BeforeSendTransaction
callback. The new option follows the same shape and matching semantics as
the existing `TagFilters`/`TracePropagationTargets` options (StringOrRegex
+ MatchesSubstringOrRegex), and is wired into BindableSentryOptions for
AOT-safe configuration binding.

Fixes getsentry#2306

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Jul 10, 2026
Adham-Kiwan and others added 2 commits July 11, 2026 02:57
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Expand the IgnoreTransactions doc comment to state that matching
transactions are dropped before the BeforeSendTransaction callback runs
(so that callback is not invoked for them), matching the JavaScript and
Python SDKs. Add a test asserting BeforeSendTransaction is not invoked
for an ignored transaction, to pin that ordering.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Adham-Kiwan

Copy link
Copy Markdown
Contributor Author

Yes — the ordering is intentional and matches the JavaScript and Python SDKs, where ignoreTransactions is handled by the built-in inbound filter that runs ahead of the user's before_send_transaction hook.

I've updated the IgnoreTransactions doc comment to state this explicitly, and added CaptureTransaction_MatchesIgnoreTransactions_BeforeSendTransactionNotInvoked, which asserts the callback is not invoked for a matched transaction, to pin the contract against accidental reordering later. Thanks for the suggestion.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c2d7ae2. Configure here.

Comment thread src/Sentry/SentryClient.cs Outdated
IgnoreTransactions is a built-in filter, so its client-report discards
should be attributed to EventProcessor (as the exception filter path
already does, and as the JS inbound filters do), rather than BeforeSend.
BeforeSend is reserved for the user's BeforeSendTransaction callback,
which does not run for an ignored transaction, so attributing the drop
to it would mislead drop-rate debugging.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Adham-Kiwan

Copy link
Copy Markdown
Contributor Author

Good catch — fixed in 1499ffc.

IgnoreTransactions now records its discards under DiscardReason.EventProcessor instead of DiscardReason.BeforeSend, matching the exception-filter path (DoSendEvent) and the JS inbound filters. BeforeSend is reserved for the user's BeforeSendTransaction callback, which doesn't run for an ignored transaction, so attributing the drop there would have misled drop-rate debugging. Updated the test assertion to match.

Comment thread src/Sentry/SentryClient.cs Outdated
Move the IgnoreTransactions filter to run after the IsSampled check, so a
transaction that is sampled out (e.g. via trace propagation) is still
attributed to sampling (SampleRate) in client reports even if its name
also matches an ignore pattern, rather than being misattributed to the
filter (EventProcessor). Sampling is the earlier, primary drop reason;
IgnoreTransactions only applies to transactions that would otherwise be
sent. Reuses the already-computed span count.

Adds a regression test asserting a sampled-out, ignore-matching
transaction is recorded under SampleRate.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Adham-Kiwan

Copy link
Copy Markdown
Contributor Author

Confirmed and fixed in 1a525c7 — this was a real (telemetry-only) issue.

The IgnoreTransactions check now runs after the IsSampled is false sampling gate. So a transaction that was sampled out (e.g. via trace propagation) is still recorded under SampleRate even if its name also matches an ignore pattern, rather than being misattributed to EventProcessor. Sampling is the earlier, primary drop reason, and IgnoreTransactions only meaningfully applies to transactions that would otherwise be sent — so this is also slightly more efficient (no filter check on already-sampled-out transactions). The check reuses the span count already computed for the sampling branch.

Added CaptureTransaction_SampledOutAndMatchesIgnoreTransactions_RecordedAsSampleRate to pin the ordering; I verified it fails if the filter is moved back ahead of the sampling check.

Comment thread CHANGELOG.md Outdated
@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 74.25%. Comparing base (0bbcf0b) to head (cc311df).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/Sentry/BindableSentryOptions.cs 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5377   +/-   ##
=======================================
  Coverage   74.25%   74.25%           
=======================================
  Files         509      509           
  Lines       18412    18420    +8     
  Branches     3604     3606    +2     
=======================================
+ Hits        13671    13677    +6     
- Misses       3868     3869    +1     
- Partials      873      874    +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jamescrosswell
jamescrosswell self-requested a review July 13, 2026 03:06
{
_options.ClientReportRecorder.RecordDiscardedEvent(DiscardReason.EventProcessor, DataCategory.Transaction);
_options.ClientReportRecorder.RecordDiscardedEvent(DiscardReason.EventProcessor, DataCategory.Span, spanCount);
_options.LogInfo("Transaction dropped by IgnoreTransactions option.");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Arguably this could be LogDebug but we can tweak that in a follow up if anyone is really unhappy with it.

@jamescrosswell jamescrosswell left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Awesome - thanks for the PR @Adham-Kiwan ! Very much appreciated 🙏🏻

This was referenced Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ignoreTransactions

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.