Skip to content

Commit

Permalink
Update sentry tracer
Browse files Browse the repository at this point in the history
  • Loading branch information
buenaflor committed Mar 4, 2024
1 parent 87d2755 commit 4dedf37
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions dart/lib/src/sentry_tracer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,24 @@ class SentryTracer extends ISentrySpan {
}

var _rootEndTimestamp = commonEndTimestamp;

// Trim the end timestamp of the transaction to the very last timestamp of child spans
if (_trimEnd && children.isNotEmpty) {
final childEndTimestamps = children
.where((child) => child.endTimestamp != null)
.map((child) => child.endTimestamp!);

if (childEndTimestamps.isNotEmpty) {
final oldestChildEndTimestamp =
childEndTimestamps.reduce((a, b) => a.isAfter(b) ? a : b);
if (_rootEndTimestamp.isAfter(oldestChildEndTimestamp)) {
_rootEndTimestamp = oldestChildEndTimestamp;
DateTime? latestEndTime;

for (var child in children) {
final childEndTimestamp = child.endTimestamp;
if (childEndTimestamp != null) {
if (latestEndTime == null ||
childEndTimestamp.isAfter(latestEndTime)) {
latestEndTime = child.endTimestamp;
}
}
}

if (latestEndTime != null) {
_rootEndTimestamp = latestEndTime;
}
}

// the callback should run before because if the span is finished,
Expand Down

0 comments on commit 4dedf37

Please sign in to comment.