Skip to content

Commit

Permalink
Add object comparison to SpanFrameMetricsCollector only check for tim…
Browse files Browse the repository at this point in the history
…e difference of .equals if objects are not the same
  • Loading branch information
lbloder committed Oct 22, 2024
1 parent 3bae1d7 commit c18a74d
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,19 @@ public class SpanFrameMetricsCollector
private final @NotNull SortedSet<ISpan> runningSpans =
new TreeSet<>(
(o1, o2) -> {
if (o1 == o2) {
return 0;
}
int timeDiff = o1.getStartDate().compareTo(o2.getStartDate());
if (timeDiff != 0) {
return timeDiff;
} else {
// TreeSet uses compareTo to check for duplicates, so ensure that
// two non-equal spans with the same start date are not considered equal
return o1.getSpanContext()
.getSpanId()
.toString()
.compareTo(o2.getSpanContext().getSpanId().toString());
}
// TreeSet uses compareTo to check for duplicates, so ensure that
// two non-equal spans with the same start date are not considered equal
return o1.getSpanContext()
.getSpanId()
.toString()
.compareTo(o2.getSpanContext().getSpanId().toString());
});

// all collected frames, sorted by frame end time
Expand Down

0 comments on commit c18a74d

Please sign in to comment.