Skip to content

Commit

Permalink
Check SpanData.latencyNanos in unit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Oberon00 committed Dec 17, 2019
1 parent bef90b7 commit b7114f0
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public void nothingChangedAfterEnd() {
startEpochNanos,
Status.OK,
/*hasEnded:*/ true);
assertThat(spanData.getLatencyNanos()).isEqualTo(0);
}

@Test
Expand All @@ -132,6 +133,7 @@ public void toSpanData_ActiveSpan() {
startEpochNanos + NANOS_PER_SECOND,
"event2",
Collections.<String, AttributeValue>emptyMap());
long prevLatencyNanos = span.getLatencyNanos();
verifySpanData(
spanData,
expectedAttributes,
Expand All @@ -142,6 +144,8 @@ public void toSpanData_ActiveSpan() {
0,
Status.OK,
/*hasEnded:*/ false);
assertThat(spanData.getLatencyNanos()).isAtLeast(prevLatencyNanos);
assertThat(spanData.getLatencyNanos()).isAtMost(span.getLatencyNanos());
assertThat(span.hasEnded()).isFalse();
} finally {
span.end();
Expand Down Expand Up @@ -174,7 +178,7 @@ public void toSpanData_EndedSpan() {
testClock.now(),
Status.CANCELLED,
/*hasEnded:*/ true);

assertThat(spanData.getLatencyNanos()).isEqualTo(testClock.now() - startEpochNanos);
}

@Test
Expand Down

0 comments on commit b7114f0

Please sign in to comment.