From 28084a5e61fa273d3754ef32143731f487bb8cc9 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Tue, 9 Jan 2024 06:19:40 +1300 Subject: [PATCH] Include unfinished spans in transactions (#3013) * Include unfinished spans in transactions * Update CHANGELOG.md * Update CHANGELOG.md --------- Co-authored-by: Bruno Garcia --- CHANGELOG.md | 5 ++++ src/Sentry/TransactionTracer.cs | 9 -------- .../Sentry.Tests/Protocol/TransactionTests.cs | 23 ------------------- 3 files changed, 5 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a8d34ac56..18a1c71ce0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/Sentry/TransactionTracer.cs b/src/Sentry/TransactionTracer.cs index e5ce135801..8202933529 100644 --- a/src/Sentry/TransactionTracer.cs +++ b/src/Sentry/TransactionTracer.cs @@ -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)); diff --git a/test/Sentry.Tests/Protocol/TransactionTests.cs b/test/Sentry.Tests/Protocol/TransactionTests.cs index 0bfa66d2bc..652ddbd402 100644 --- a/test/Sentry.Tests/Protocol/TransactionTests.cs +++ b/test/Sentry.Tests/Protocol/TransactionTests.cs @@ -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() {