Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
Simplify `SpanDataMatchers#hasDuration` to work explicitly with `Duration` instances.
  • Loading branch information
ndimiduk committed Jan 24, 2022
1 parent 2e7bc1b commit 9328e54
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,12 @@ public static Matcher<SpanData> hasAttributes(Matcher<Attributes> matcher) {
};
}

public static <T extends Comparable<T> & TemporalAmount> Matcher<SpanData> hasDuration(
Matcher<T> matcher
) {
return new FeatureMatcher<SpanData, T>(matcher, "SpanData having duration that ", "duration") {
public static Matcher<SpanData> hasDuration(Matcher<Duration> matcher) {
return new FeatureMatcher<SpanData, Duration>(
matcher, "SpanData having duration that ", "duration") {
@Override
@SuppressWarnings("unchecked")
protected T featureValueOf(SpanData item) {
return (T) Duration.ofNanos(item.getEndEpochNanos() - item.getStartEpochNanos());
protected Duration featureValueOf(SpanData item) {
return Duration.ofNanos(item.getEndEpochNanos() - item.getStartEpochNanos());
}
};
}
Expand Down

0 comments on commit 9328e54

Please sign in to comment.