Skip to content
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

Set default trace status to ok instead of unknown_error #1970

Merged
merged 4 commits into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
- Tags should not differ based on current culture ([#1949](https://github.com/getsentry/sentry-dotnet/pull/1949))
- Always recalculate payload length ([#1957](https://github.com/getsentry/sentry-dotnet/pull/1957))
- Fix issues with envelope deserialization ([#1965](https://github.com/getsentry/sentry-dotnet/pull/1965))
- Set default trace status to `ok` instead of `unknown_error` ([#1970](https://github.com/getsentry/sentry-dotnet/pull/1970))

## 3.21.0

Expand Down
2 changes: 1 addition & 1 deletion src/Sentry/SpanTracer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public class SpanTracer : ISpan
/// <inheritdoc />
public void Finish()
{
Status ??= SpanStatus.UnknownError;
Status ??= SpanStatus.Ok;
EndTimestamp = _stopwatch.CurrentDateTimeOffset;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Sentry/TransactionTracer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ internal ISpan StartChild(SpanId parentSpanId, string operation)
/// <inheritdoc />
public void Finish()
{
Status ??= SpanStatus.UnknownError;
Status ??= SpanStatus.Ok;
EndTimestamp = _stopwatch.CurrentDateTimeOffset;

foreach (var span in _spans)
Expand Down
35 changes: 33 additions & 2 deletions test/Sentry.Tests/Protocol/TransactionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ public void Finish_LinksExceptionToEvent()
}

[Fact]
public void Finish_NoStatus_DefaultsToUnknown()
public void Finish_NoStatus_DefaultsToOk()
{
// Arrange
var hub = Substitute.For<IHub>();
Expand All @@ -312,7 +312,7 @@ public void Finish_NoStatus_DefaultsToUnknown()
transaction.Finish();

// Assert
transaction.Status.Should().Be(SpanStatus.UnknownError);
transaction.Status.Should().Be(SpanStatus.Ok);
}

[Fact]
Expand All @@ -331,4 +331,35 @@ public void Finish_StatusSet_DoesNotOverride()
// Assert
transaction.Status.Should().Be(SpanStatus.DataLoss);
}

[Fact]
public void Finish_ChildSpan_NoStatus_DefaultsToOk()
{
// Arrange
var hub = Substitute.For<IHub>();
var transaction = new TransactionTracer(hub, "my name", "my op");
var span = transaction.StartChild("child op");

// Act
span.Finish();

// Assert
span.Status.Should().Be(SpanStatus.Ok);
}

[Fact]
public void Finish_ChildSpan_StatusSet_DoesNotOverride()
{
// Arrange
var hub = Substitute.For<IHub>();
var transaction = new TransactionTracer(hub, "my name", "my op");
var span = transaction.StartChild("child op");
span.Status = SpanStatus.DataLoss;

// Act
span.Finish();

// Assert
span.Status.Should().Be(SpanStatus.DataLoss);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
Platform: csharp,
Operation: my operation,
Description: ,
Status: UnknownError,
Status: Ok,
IsSampled: true,
SampleRate: 1.0,
Request: {},
Expand All @@ -69,7 +69,7 @@
trace: {
Operation: my operation,
Description: ,
Status: UnknownError,
Status: Ok,
IsSampled: true
}
},
Expand Down