Skip to content

Commit

Permalink
Include unfinished spans in transactions (#3013)
Browse files Browse the repository at this point in the history
* Include unfinished spans in transactions

* Update CHANGELOG.md

* Update CHANGELOG.md

---------

Co-authored-by: Bruno Garcia <[email protected]>
  • Loading branch information
jamescrosswell and bruno-garcia authored Jan 8, 2024
1 parent f93d62b commit 28084a5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 32 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Unreleased

### Significant change in behavior

- Transactions' spans are no longer automatically finished with status `deadline_exceeded` by the transaction. This is now handled by the [Relay](https://github.com/getsentry/relay).
- Customers self hosting Sentry must use verion 22.12.0 or later ([#3013](https://github.com/getsentry/sentry-dotnet/pull/3013))

### API breaking Changes

#### Changed APIs
Expand Down
9 changes: 0 additions & 9 deletions src/Sentry/TransactionTracer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -370,15 +370,6 @@ public void Finish()
EndTimestamp ??= _stopwatch.CurrentDateTimeOffset;
_options?.LogDebug("Finished Transaction {0}.", SpanId);

foreach (var span in _spans)
{
if (!span.IsFinished)
{
_options?.LogDebug("Deadline exceeded for Transaction {0} -> Span {1}.", SpanId, span.SpanId);
span.Finish(SpanStatus.DeadlineExceeded);
}
}

// Clear the transaction from the scope
_hub.ConfigureScope(scope => scope.ResetTransaction(this));

Expand Down
23 changes: 0 additions & 23 deletions test/Sentry.Tests/Protocol/TransactionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -380,29 +380,6 @@ public void Finish_RecordsTime()
(transaction.EndTimestamp - transaction.StartTimestamp).Should().BeGreaterOrEqualTo(TimeSpan.Zero);
}

[Fact]
public void Finish_UnfinishedSpansGetsFinishedWithDeadlineStatus()
{
// Arrange
var transaction = new TransactionTracer(DisabledHub.Instance, "my name", "my op");
transaction.StartChild("children1");
transaction.StartChild("children2");
transaction.StartChild("children3.finished").Finish(SpanStatus.Ok);
transaction.StartChild("children4");

// Act
transaction.Finish();

// Assert

Assert.All(transaction.Spans.Where(span => !span.Operation.EndsWith("finished")), span =>
{
Assert.True(span.IsFinished);
Assert.Equal(SpanStatus.DeadlineExceeded, span.Status);
});
Assert.Single(transaction.Spans.Where(span => span.Operation.EndsWith("finished") && span.Status == SpanStatus.Ok));
}

[Fact]
public void Finish_SentryRequestSpansGetIgnored()
{
Expand Down

0 comments on commit 28084a5

Please sign in to comment.