-
-
Notifications
You must be signed in to change notification settings - Fork 226
Improve SentryHttpFailedRequestHandler issue grouping #4724
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
Merged
jamescrosswell
merged 21 commits into
getsentry:main
from
eaze:SentryHttpMessageHandler-issue-grouping
Nov 19, 2025
Merged
Changes from 14 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
19c0b76
Add new HttpStatusCodeRangeExtensions and tests.
ericsampson 8b3ea27
Improve tests.
ericsampson 56e3bf8
Add test that currently fails to prove the fix works.
ericsampson b97a6bd
Enhance the HttpFailedRequestHandler so that it captures a full excep…
ericsampson fd65e67
Merge branch 'main' into SentryHttpMessageHandler-issue-grouping
ericsampson 02e69b1
Delete tests for deleted functionality.
ericsampson c9da3c7
Update test/Sentry.Tests/HttpStatusCodeRangeExtensionsTests.cs
ericsampson a07ed5d
Switch to using ExceptionDispatchInfo.SetCurrentStackTrace
ericsampson c4b981d
Update re PR feedback
ericsampson ced8585
Update with PR feedback
ericsampson 7a1573a
PR feedback
ericsampson 02a16b4
PR feedback
ericsampson 77132f5
Add note to changelog
ericsampson 46bcc41
Update src/Sentry/SentryHttpFailedRequestHandler.cs
ericsampson 70232c3
Update src/Sentry/SentryHttpFailedRequestHandler.cs re method availab…
ericsampson 7a90dac
format test/Sentry.Tests/SentryHttpFailedRequestHandlerTests.cs
ericsampson f8edf37
Update test for running on .NET5+
ericsampson e3fc2bc
Merge branch 'main' into SentryHttpMessageHandler-issue-grouping
ericsampson c76afd1
update Changelog re PR feedback
ericsampson 885d728
Update CHANGELOG.md
ericsampson 3901dd0
Merge branch 'main' into SentryHttpMessageHandler-issue-grouping
ericsampson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ericsampson marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| namespace Sentry; | ||
|
|
||
| /// <summary> | ||
| /// Extension methods for collections of <see cref="HttpStatusCodeRange"/>. | ||
| /// </summary> | ||
| internal static class HttpStatusCodeRangeExtensions | ||
| { | ||
| /// <summary> | ||
| /// Checks if any range in the collection contains the given status code. | ||
| /// </summary> | ||
| /// <param name="ranges">Collection of ranges to check.</param> | ||
| /// <param name="statusCode">Status code to check.</param> | ||
| /// <returns>True if any range contains the given status code.</returns> | ||
| internal static bool ContainsStatusCode(this IEnumerable<HttpStatusCodeRange> ranges, int statusCode) | ||
ericsampson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| => ranges.Any(range => range.Contains(statusCode)); | ||
|
|
||
| /// <summary> | ||
| /// Checks if any range in the collection contains the given status code. | ||
| /// </summary> | ||
| /// <param name="ranges">Collection of ranges to check.</param> | ||
| /// <param name="statusCode">Status code to check.</param> | ||
| /// <returns>True if any range contains the given status code.</returns> | ||
| internal static bool ContainsStatusCode(this IEnumerable<HttpStatusCodeRange> ranges, HttpStatusCode statusCode) | ||
| => ranges.ContainsStatusCode((int)statusCode); | ||
| } | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
171 changes: 171 additions & 0 deletions
171
test/Sentry.Tests/HttpStatusCodeRangeExtensionsTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,171 @@ | ||
| namespace Sentry.Tests; | ||
|
|
||
| public class HttpStatusCodeRangeExtensionsTests | ||
| { | ||
| [Fact] | ||
| public void ContainsStatusCode_EmptyList_ReturnsFalse() | ||
| { | ||
| // Arrange | ||
| var ranges = new List<HttpStatusCodeRange>(); | ||
|
|
||
| // Act | ||
| var result = ranges.ContainsStatusCode(404); | ||
|
|
||
| // Assert | ||
| result.Should().BeFalse(); | ||
| } | ||
|
|
||
| [Theory] | ||
| [InlineData(400)] | ||
| [InlineData(450)] | ||
| [InlineData(499)] | ||
| public void ContainsStatusCode_SingleRangeInRange_ReturnsTrue(int statusCode) | ||
| { | ||
| // Arrange | ||
| var ranges = new List<HttpStatusCodeRange> { (400, 499) }; | ||
|
|
||
| // Act | ||
| var result = ranges.ContainsStatusCode(statusCode); | ||
|
|
||
| // Assert | ||
| result.Should().BeTrue(); | ||
| } | ||
|
|
||
| [Theory] | ||
| [InlineData(200)] | ||
| [InlineData(399)] | ||
| [InlineData(500)] | ||
| public void ContainsStatusCode_SingleRangeOutOfRange_ReturnsFalse(int statusCode) | ||
| { | ||
| // Arrange | ||
| var ranges = new List<HttpStatusCodeRange> { (400, 499) }; | ||
|
|
||
| // Act | ||
| var result = ranges.ContainsStatusCode(statusCode); | ||
|
|
||
| // Assert | ||
| result.Should().BeFalse(); | ||
| } | ||
|
|
||
| [Theory] | ||
| [InlineData(400)] // In first range | ||
| [InlineData(404)] // In first range | ||
| [InlineData(500)] // In second range | ||
| [InlineData(503)] // In second range | ||
| public void ContainsStatusCode_MultipleRangesInAnyRange_ReturnsTrue(int statusCode) | ||
| { | ||
| // Arrange | ||
| var ranges = new List<HttpStatusCodeRange> { (400, 404), (500, 503) }; | ||
|
|
||
| // Act | ||
| var result = ranges.ContainsStatusCode(statusCode); | ||
|
|
||
| // Assert | ||
| result.Should().BeTrue(); | ||
| } | ||
|
|
||
| [Theory] | ||
| [InlineData(200)] // Below ranges | ||
| [InlineData(405)] // Between ranges | ||
| [InlineData(499)] // Between ranges | ||
| [InlineData(504)] // Above ranges | ||
| public void ContainsStatusCode_MultipleRangesNotInAnyRange_ReturnsFalse(int statusCode) | ||
| { | ||
| // Arrange | ||
| var ranges = new List<HttpStatusCodeRange> { (400, 404), (500, 503) }; | ||
|
|
||
| // Act | ||
| var result = ranges.ContainsStatusCode(statusCode); | ||
|
|
||
| // Assert | ||
| result.Should().BeFalse(); | ||
| } | ||
|
|
||
| [Theory] | ||
| [InlineData(400)] // In first range only | ||
| [InlineData(425)] // In overlap | ||
| [InlineData(450)] // In overlap | ||
| [InlineData(475)] // In second range only | ||
| public void ContainsStatusCode_OverlappingRangesInUnion_ReturnsTrue(int statusCode) | ||
| { | ||
| // Arrange | ||
| var ranges = new List<HttpStatusCodeRange> { (400, 450), (425, 475) }; | ||
|
|
||
| // Act | ||
| var result = ranges.ContainsStatusCode(statusCode); | ||
|
|
||
| // Assert | ||
| result.Should().BeTrue(); | ||
| } | ||
|
|
||
| [Theory] | ||
| [InlineData(200)] // Below first range | ||
| [InlineData(399)] // Below first range | ||
| [InlineData(476)] // Above second range | ||
| [InlineData(500)] // Above second range | ||
| public void ContainsStatusCode_OverlappingRangesOutsideUnion_ReturnsFalse(int statusCode) | ||
| { | ||
| // Arrange | ||
| var ranges = new List<HttpStatusCodeRange> { (400, 450), (425, 475) }; | ||
|
|
||
| // Act | ||
| var result = ranges.ContainsStatusCode(statusCode); | ||
|
|
||
| // Assert | ||
| result.Should().BeFalse(); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ContainsStatusCode_SingleValueRangeExactMatch_ReturnsTrue() | ||
| { | ||
| // Arrange | ||
| var ranges = new List<HttpStatusCodeRange> { 404 }; | ||
|
|
||
| // Act | ||
| var result = ranges.ContainsStatusCode(404); | ||
|
|
||
| // Assert | ||
| result.Should().BeTrue(); | ||
| } | ||
|
|
||
| [Theory] | ||
| [InlineData(403)] | ||
| [InlineData(405)] | ||
| public void ContainsStatusCode_SingleValueRangeNoMatch_ReturnsFalse(int statusCode) | ||
| { | ||
| // Arrange | ||
| var ranges = new List<HttpStatusCodeRange> { 404 }; | ||
|
|
||
| // Act | ||
| var result = ranges.ContainsStatusCode(statusCode); | ||
|
|
||
| // Assert | ||
| result.Should().BeFalse(); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ContainsStatusCode_HttpStatusCodeEnumInRange_ReturnsTrue() | ||
| { | ||
| // Arrange | ||
| var ranges = new List<HttpStatusCodeRange> { (400, 499) }; | ||
|
|
||
| // Act | ||
| var result = ranges.ContainsStatusCode(HttpStatusCode.NotFound); // 404 | ||
|
|
||
| // Assert | ||
| result.Should().BeTrue(); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ContainsStatusCode_HttpStatusCodeEnumOutOfRange_ReturnsFalse() | ||
| { | ||
| // Arrange | ||
| var ranges = new List<HttpStatusCodeRange> { (400, 499) }; | ||
|
|
||
| // Act | ||
| var result = ranges.ContainsStatusCode(HttpStatusCode.OK); // 200 | ||
|
|
||
| // Assert | ||
| result.Should().BeFalse(); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.