Support status code ranges when configuring TraceIgnoreStatusCodes from appsettings.json

Open
#5,644 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
68/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
csharp

Research direction

Start by locating BindableSentryOptions.TraceIgnoreStatusCodes and its ApplyTo method, then inspect how configuration binding and status-code defaults are tested. Support numeric strings and inclusive ranges while preserving existing numeric configurations; verify that configured ranges and individual codes produce the expected ignored statuses, and clarify whether FailedRequestStatusCodes is included.

Written by the indexing model from the issue text.

Description

.NET Improvement State: Needs Discussion Traces

TraceIgnoreStatusCodes can be set from configuration, but only as a list of individual status codes: BindableSentryOptions.TraceIgnoreStatusCodes is a List<int>. Configuration can't express a range, and "TraceIgnoreStatusCodes": [ "305-399" ] throws an InvalidOperationException at startup.

This matters more in 7.0, where the default becomes [301, (305, 399), (401, 404)] (#5632). Configuration replaces the default rather than adding to it, so keeping the default and ignoring one more code from appsettings.json means listing around 100 integers.

Proposal

Change the bindable property to a List<string> and parse each entry in ApplyTo as either a single code ("404") or an inclusive range ("305-399"). JSON numbers bind to string without problems, so existing configs like [ 404, 429 ] keep working.

"Sentry": {
  "TraceIgnoreStatusCodes": [ 301, "305-399", "401-404", 429 ]
}

FailedRequestStatusCodes has no bindable equivalent at all today, so it could get the same treatment.

Raised by @ric-oliv in https://github.com/getsentry/sentry-dotnet/pull/5632#issuecomment-5892916655

Dominant language
C#
Stars
775
Forks
262
Avg merge
1d 16h
Merged PRs (30d)
118

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from getsentry/sentry-dotnet

All issues in getsentry/sentry-dotnet

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.