Skip to content

feat: Add option to exclude certain HTTP statuses from tracing#5034

Merged
jamescrosswell merged 13 commits intomainfrom
trace-ignore-status-codes
Apr 15, 2026
Merged

feat: Add option to exclude certain HTTP statuses from tracing#5034
jamescrosswell merged 13 commits intomainfrom
trace-ignore-status-codes

Conversation

@jamescrosswell
Copy link
Copy Markdown
Collaborator

@jamescrosswell jamescrosswell commented Mar 17, 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 17, 2026

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Breaking Changes 🛠

  • The _Metrics_ APIs are now stable: removed Experimental from SentrySdk, SentryOptions and IHub by Flash0ver in #5023

Features ✨

  • Report a new _Diagnostic_ (SENTRY1001) when a Metrics-API is invoked with an unsupported numeric type by Flash0ver in #4840
  • feat: Add option to exclude certain HTTP statuses from tracing by jamescrosswell in #5034

Fixes 🐛

  • fix: include Data set via ITransactionTracer in SentryTransaction by Flash0ver in #4148
  • fix: CaptureFeedback now applies event processors by jamescrosswell in #4942

Dependencies ⬆️

Deps

  • chore(deps): update Java SDK to v8.36.0 by github-actions in #5036
  • chore(deps): update epitaph to 0.1.1 by github-actions in #5036
  • chore(deps): update Native SDK to v0.13.3 by github-actions in #5045
  • chore(deps): update Cocoa SDK to v9.7.0 by github-actions in #5015
  • chore(deps): update Java SDK to v8.35.0 by github-actions in #5017
  • chore(deps): replaced the heavy protobuf-javalite 3.25.8 dependency with a light-weight epitaph 0.1.0 alternative on Android (getsentry/sentry-java#5157) by github-actions in #5017
  • chore(deps): update CLI to v3.3.3 by github-actions in #5002
  • chore(deps): update Cocoa SDK to v9.6.0 by github-actions in #4958

Other

  • ref: Use .NET 6.0 ArgumentNullException throw helpers by copilot-swe-agent in #4985

🤖 This preview updates automatically when you update the PR.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 17, 2026

Codecov Report

❌ Patch coverage is 88.88889% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.02%. Comparing base (58c1a81) to head (9393cdc).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
...or.WebAssembly/WebAssemblyHostBuilderExtensions.cs 0.00% 1 Missing ⚠️
src/Sentry/BindableSentryOptions.cs 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5034   +/-   ##
=======================================
  Coverage   74.02%   74.02%           
=======================================
  Files         499      500    +1     
  Lines       18049    18063   +14     
  Branches     3512     3515    +3     
=======================================
+ Hits        13361    13372   +11     
- Misses       3831     3837    +6     
+ Partials      857      854    -3     

☔ View full report in Codecov by Sentry.
📢 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.

Comment thread src/Sentry/Internal/TraceIgnoreStatusCodeTransactionProcessor.cs
@jamescrosswell jamescrosswell changed the base branch from main to fix/transaction/tracer-setdata-not-sent March 18, 2026 00:23
@jamescrosswell jamescrosswell changed the base branch from fix/transaction/tracer-setdata-not-sent to main March 18, 2026 00:23
Comment thread src/Sentry/SentryOptions.cs Outdated
@jamescrosswell jamescrosswell marked this pull request as ready for review March 22, 2026 21:55
Comment thread src/Sentry/SentryOptions.cs
&& statusCodeObj is int statusCode
&& _options.TraceIgnoreStatusCodes.ContainsStatusCode(statusCode))
{
return null;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

question: Sampling Decision

From the dev docs:

If the value of this attribute matches one of the status codes in traceIgnoreStatusCodes, the SDK MUST set the transaction's sampling decision to not sampled.

Should this have other effects as well,
like setting the "sample_rate" on the DynamicSamplingContext as well,
or am I misunderstanding something there?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

At this stage, the Dynamic Sampling Context is no longer relevant... the transaction tracer has already been finished and a snapshot of the transaction has been created in the form of a SentryTransaction (a more or less immutable DTO - certainly it's not used for tracing any longer). Any outbound requests that were made using the DSC have already been completed so there's no way to retrospectively change the sample rate that was communicated for those.

Comment thread src/Sentry/Internal/TraceIgnoreStatusCodeTransactionProcessor.cs Outdated
Comment thread src/Sentry/BindableSentryOptions.cs
public string? CacheDirectoryPath { get; set; }
public bool? CaptureFailedRequests { get; set; }
public List<string>? FailedRequestTargets { get; set; }
public List<int>? TraceIgnoreStatusCodes { get; set; }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

issue: potential inconsistency

I wanted to check whether we are consistent with the other IList<HttpStatusCodeRange>-based Option, which is FailedRequestStatusCodes.

But FailedRequestStatusCodes does not exist on the BindableSentryOptions.

Now I'm wondering, whether BindableSentryOptions.FailedRequestStatusCodes does not exist because

  • we forgot it
  • we didn't add it because of scalar status codes vs Status-Code-Ranges

If the reasoning is the latter, then I guess we should not add this BindableSentryOptions as well, for consistency.

If, instead of only allowing scalar bindable options,
we also want to be able to depict Ranges via BindableSentryOptions, perhaps we could enable parsing from

{
  "Sentry": {
    "TraceIgnoreStatusCodes": [[301, 303], [305, 399], [401, 404]],
    "TraceIgnoreStatusCodes": [ {"start": 301, "end": 303}, {"start": 305, "end": 399}, {"start": 401, "end":404}]
  }
}

or something like that.

If we'd like to do that, for both this TraceIgnoreStatusCodes, and the already existing SentryOptions.FailedRequestStatusCodes, perhaps we want to hold off on this Bindable-Option for now, and introduce Bindable-HttpStatusCodeRange-Collections in a separate issue/PR.

What do you think?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

But FailedRequestStatusCodes does not exist on the BindableSentryOptions.

Ideally as many of the options as possible would also be configurable via bindings (e.g. apssettings.json).

I think I didn't solve for FailedRequestStatusCodes specifically because the broader AOT problem was huge in scope. The shortest path to completion was simply to omit any non trivial properties (primitives) from the bindable options and require SDK users configure these instead via code.

I'm not really sure how many people will use the configuration bindings for these two properties, so a relatively simple solution to start with is probably not a bad thing. This PR adds the ability to configure lists of explicit codes to ignore via bindings... if people want to do more complex things like ranges, that would have to be done in code.

We could create a custom binding that was more sophisticated... it's certainly technically possible but would date longer to build and test. We have a backlog of over 300 issues so I'd recommend we just go with this simpler solution for the time being (or omit the ability to configure trace ignore status codes via bindings entirely).

We could also, for consistency, add an issue to the backlog to enable some similar bindable options for FailedRequestStatusCodes... with a medium priority initially (unless we get feedback from the community that this would be useful).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Added #5061 as a follow up task to address the inconsistency:

Comment thread src/Sentry/SentryOptions.cs Outdated
Comment thread src/Sentry/SentryOptions.cs Outdated
Comment thread test/Sentry.Tests/TraceIgnoreStatusCodeTransactionProcessorTests.cs
Comment thread test/Sentry.Tests/TraceIgnoreStatusCodeTransactionProcessorTests.cs Outdated
Comment thread src/Sentry/Internal/TraceIgnoreStatusCodeTransactionProcessor.cs
Copy link
Copy Markdown

@cursor cursor Bot left a comment

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 2 potential issues.

Fix All in Cursor

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

Comment thread src/Sentry/Internal/TraceIgnoreStatusCodeTransactionProcessor.cs Outdated
Comment thread src/Sentry.AspNet/SentryAspNetOptionsExtensions.cs
@jamescrosswell jamescrosswell marked this pull request as draft March 24, 2026 07:55
@jamescrosswell jamescrosswell marked this pull request as ready for review March 25, 2026 01:09
@jamescrosswell jamescrosswell requested a review from jpnurmi April 15, 2026 07:18
evgenygunko pushed a commit to evgenygunko/CopyWordsDA that referenced this pull request Apr 17, 2026
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [Sentry.Maui](https://sentry.io/) ([source](https://github.com/getsentry/sentry-dotnet)) | nuget | minor | `6.3.2` -> `6.4.0` |

---

### Release Notes

<details>
<summary>getsentry/sentry-dotnet (Sentry.Maui)</summary>

### [`v6.4.0`](https://github.com/getsentry/sentry-dotnet/blob/HEAD/CHANGELOG.md#640)

[Compare Source](getsentry/sentry-dotnet@6.3.2...6.4.0)

##### Features ✨

-   feat: Add network details for session replay on iOS by [@&#8203;jamescrosswell](https://github.com/jamescrosswell) in [#&#8203;4891](getsentry/sentry-dotnet#4891)
-   feat: Add option to exclude certain HTTP statuses from tracing by [@&#8203;jamescrosswell](https://github.com/jamescrosswell) in [#&#8203;5034](getsentry/sentry-dotnet#5034)

##### Fixes 🐛

-   fix: memory leak when profiling is enabled by [@&#8203;jamescrosswell](https://github.com/jamescrosswell) in [#&#8203;5133](getsentry/sentry-dotnet#5133)
-   fix: prevent redundant native exceptions on iOS by [@&#8203;jpnurmi](https://github.com/jpnurmi) in [#&#8203;5126](getsentry/sentry-dotnet#5126)
-   fix: prevent redundant native exceptions on Android/Mono by [@&#8203;jpnurmi](https://github.com/jpnurmi) in [#&#8203;4676](getsentry/sentry-dotnet#4676)
    -   Note: opt in by setting `options.Native.ExperimentalOptions.SignalHandlerStrategy` to `Sentry.Android.SignalHandlerStrategy.ChainAtStart`

##### Dependencies ⬆️

##### Deps

-   chore(deps): update Cocoa SDK to v9.10.0 by [@&#8203;github-actions](https://github.com/github-actions) in [#&#8203;5132](getsentry/sentry-dotnet#5132)
-   chore(deps): update Cocoa SDK to v9.9.0 by [@&#8203;github-actions](https://github.com/github-actions) in [#&#8203;5115](getsentry/sentry-dotnet#5115)
-   chore(deps): update Java SDK to v8.38.0 by [@&#8203;github-actions](https://github.com/github-actions) in [#&#8203;5124](getsentry/sentry-dotnet#5124)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or PR is renamed to start with "rebase!".

👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired.

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
github-merge-queue Bot pushed a commit to DFE-Digital/teaching-record-system that referenced this pull request Apr 20, 2026
Updated [Sentry.AspNetCore](https://github.com/getsentry/sentry-dotnet)
from 6.3.2 to 6.4.0.

<details>
<summary>Release notes</summary>

_Sourced from [Sentry.AspNetCore's
releases](https://github.com/getsentry/sentry-dotnet/releases)._

## 6.4.0

### Features ✨

- feat: Add network details for session replay on iOS by
@​jamescrosswell in
[#​4891](getsentry/sentry-dotnet#4891)
- feat: Add option to exclude certain HTTP statuses from tracing by
@​jamescrosswell in
[#​5034](getsentry/sentry-dotnet#5034)

### Fixes 🐛

- fix: memory leak when profiling is enabled by @​jamescrosswell in
[#​5133](getsentry/sentry-dotnet#5133)
- fix: prevent redundant native exceptions on iOS by @​jpnurmi in
[#​5126](getsentry/sentry-dotnet#5126)
- fix: prevent redundant native exceptions on Android/Mono by @​jpnurmi
in [#​4676](getsentry/sentry-dotnet#4676)
- Note: opt in by setting
`options.Native.ExperimentalOptions.SignalHandlerStrategy` to
`Sentry.Android.SignalHandlerStrategy.ChainAtStart`

### Dependencies ⬆️

#### Deps

- chore(deps): update Cocoa SDK to v9.10.0 by @​github-actions in
[#​5132](getsentry/sentry-dotnet#5132)
- chore(deps): update Cocoa SDK to v9.9.0 by @​github-actions in
[#​5115](getsentry/sentry-dotnet#5115)
- chore(deps): update Java SDK to v8.38.0 by @​github-actions in
[#​5124](getsentry/sentry-dotnet#5124)

Commits viewable in [compare
view](getsentry/sentry-dotnet@6.3.2...6.4.0).
</details>

Updated
[Sentry.Extensions.Logging](https://github.com/getsentry/sentry-dotnet)
from 6.3.2 to 6.4.0.

<details>
<summary>Release notes</summary>

_Sourced from [Sentry.Extensions.Logging's
releases](https://github.com/getsentry/sentry-dotnet/releases)._

## 6.4.0

### Features ✨

- feat: Add network details for session replay on iOS by
@​jamescrosswell in
[#​4891](getsentry/sentry-dotnet#4891)
- feat: Add option to exclude certain HTTP statuses from tracing by
@​jamescrosswell in
[#​5034](getsentry/sentry-dotnet#5034)

### Fixes 🐛

- fix: memory leak when profiling is enabled by @​jamescrosswell in
[#​5133](getsentry/sentry-dotnet#5133)
- fix: prevent redundant native exceptions on iOS by @​jpnurmi in
[#​5126](getsentry/sentry-dotnet#5126)
- fix: prevent redundant native exceptions on Android/Mono by @​jpnurmi
in [#​4676](getsentry/sentry-dotnet#4676)
- Note: opt in by setting
`options.Native.ExperimentalOptions.SignalHandlerStrategy` to
`Sentry.Android.SignalHandlerStrategy.ChainAtStart`

### Dependencies ⬆️

#### Deps

- chore(deps): update Cocoa SDK to v9.10.0 by @​github-actions in
[#​5132](getsentry/sentry-dotnet#5132)
- chore(deps): update Cocoa SDK to v9.9.0 by @​github-actions in
[#​5115](getsentry/sentry-dotnet#5115)
- chore(deps): update Java SDK to v8.38.0 by @​github-actions in
[#​5124](getsentry/sentry-dotnet#5124)

Commits viewable in [compare
view](getsentry/sentry-dotnet@6.3.2...6.4.0).
</details>

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions


</details>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: James Gunn <james@gunn.io>
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.

Add option to exclude certain HTTP statuses from tracing in SDK

4 participants