diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4500a674bc..1745527dab 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@
### Fixes
- `IHub.ResumeSession()`: don't start a new session if pause wasn't called or if there is no active session ([#1089](https://github.com/getsentry/sentry-dotnet/pull/1089))
+- Fixed incorrect order when getting the last active span ([#1094](https://github.com/getsentry/sentry-dotnet/pull/1094))
- Fix logger call in BackgroundWorker that caused a formatting exception in runtime ([#1092](https://github.com/getsentry/sentry-dotnet/pull/1092))
## 3.6.0
diff --git a/src/Sentry/TransactionTracer.cs b/src/Sentry/TransactionTracer.cs
index 63a02ac5fa..1a8203aa1f 100644
--- a/src/Sentry/TransactionTracer.cs
+++ b/src/Sentry/TransactionTracer.cs
@@ -253,7 +253,9 @@ public void Finish(Exception exception) =>
Finish(exception, SpanStatusConverter.FromException(exception));
///
- public ISpan? GetLastActiveSpan() => Spans.LastOrDefault(s => !s.IsFinished);
+ public ISpan? GetLastActiveSpan() =>
+ // We need to sort by timestamp because the order of ConcurrentBag is not deterministic
+ Spans.OrderByDescending(x => x.StartTimestamp).FirstOrDefault(s => !s.IsFinished);
///
public SentryTraceHeader GetTraceHeader() => new(