Skip to content

Commit

Permalink
Merge branch 'ref/internal-error-on-transaction-with-exception' of ht…
Browse files Browse the repository at this point in the history
…tps://github.com/getsentry/sentry-dotnet into ref/internal-error-on-transaction-with-exception
  • Loading branch information
lucas-zimerman committed Jul 27, 2021
2 parents 7625410 + b5b260b commit 0ab7f56
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fixes

- Set error status to transaction if http has exception and ok status ([#1143](https://github.com/getsentry/sentry-dotnet/pull/1143))
- Fix max breadcrumbs limit when MaxBreadcrumbs is zero or lower ([#1145](https://github.com/getsentry/sentry-dotnet/pull/1145))

## 3.8.3

Expand Down
9 changes: 6 additions & 3 deletions src/Sentry/Scope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,12 @@ public void AddBreadcrumb(Breadcrumb breadcrumb)
}
}

var overflow = Breadcrumbs.Count - Options.MaxBreadcrumbs + 1;

if (overflow > 0)
if (Options.MaxBreadcrumbs <= 0)
{
//Always drop the breadcrumb.
return;
}
else if (Breadcrumbs.Count - Options.MaxBreadcrumbs + 1 > 0)
{
_breadcrumbs.TryDequeue(out _);
}
Expand Down
25 changes: 25 additions & 0 deletions test/Sentry.Tests/ScopeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,5 +254,30 @@ public void ClearAttachments_HasAttachments_EmptyList()
//Assert
scope.Attachments.Should().BeEmpty();
}

[Theory]
[InlineData(0, -2, 0)]
[InlineData(0, -1, 0)]
[InlineData(0, 0, 0)]
[InlineData(0, 1, 1)]
[InlineData(0, 2, 1)]
[InlineData(1, 2, 2)]
[InlineData(2, 2, 2)]
public void AddBreadcrumb__AddBreadcrumb_RespectLimits(int initialCount, int maxBreadcrumbs, int expectedCount)
{
//Arrange
var scope = new Scope(new SentryOptions() { MaxBreadcrumbs = maxBreadcrumbs });

for (int i = 0; i < initialCount; i++)
{
scope.AddBreadcrumb(new Breadcrumb());
}

//Act
scope.AddBreadcrumb(new Breadcrumb());

//Assert
Assert.Equal(expectedCount, scope.Breadcrumbs.Count);
}
}
}

0 comments on commit 0ab7f56

Please sign in to comment.