File tree 1 file changed +15
-9
lines changed
1 file changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -109,18 +109,24 @@ class SentryTracer extends ISentrySpan {
109
109
}
110
110
111
111
var _rootEndTimestamp = commonEndTimestamp;
112
+
113
+ // Trim the end timestamp of the transaction to the very last timestamp of child spans
112
114
if (_trimEnd && children.isNotEmpty) {
113
- final childEndTimestamps = children
114
- . where ((child) => child.endTimestamp != null )
115
- . map (( child) => child.endTimestamp ! );
116
-
117
- if (childEndTimestamps.isNotEmpty ) {
118
- final oldestChildEndTimestamp =
119
- childEndTimestamps. reduce ((a, b) => a .isAfter (b) ? a : b);
120
- if (_rootEndTimestamp. isAfter (oldestChildEndTimestamp)) {
121
- _rootEndTimestamp = oldestChildEndTimestamp;
115
+ DateTime ? latestEndTime;
116
+
117
+ for ( var child in children) {
118
+ final childEndTimestamp = child.endTimestamp;
119
+ if (childEndTimestamp != null ) {
120
+ if (latestEndTime == null ||
121
+ childEndTimestamp .isAfter (latestEndTime)) {
122
+ latestEndTime = child.endTimestamp;
123
+ }
122
124
}
123
125
}
126
+
127
+ if (latestEndTime != null ) {
128
+ _rootEndTimestamp = latestEndTime;
129
+ }
124
130
}
125
131
126
132
// the callback should run before because if the span is finished,
You can’t perform that action at this time.
0 commit comments