Skip to content

Commit

Permalink
Fix RntbdRequestTimeline Duration (Azure#17891)
Browse files Browse the repository at this point in the history
* fix requestTimeline Duration

Co-authored-by: Annie Liang <xinlian@microsoft.com>
  • Loading branch information
xinlian12 and Annie Liang authored Dec 1, 2020
1 parent 1ea92d4 commit a856480
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,15 @@ public String toString() {
return RntbdObjectMapper.toString(this);
}

@JsonPropertyOrder({ "name", "startTimeUTC" })
@JsonPropertyOrder({ "name", "startTimeUTC", "durationInMicroSec" })
public static final class Event {

@JsonIgnore
private final Duration duration;

@JsonProperty
private final long durationInMicroSec;

@JsonProperty("eventName")
private final String name;

Expand All @@ -178,6 +181,12 @@ public Event(final String name, final Instant from, final Instant to) {
} else {
this.duration = Duration.between(from, to);
}

if (duration != null) {
this.durationInMicroSec = duration.toNanos()/1000L;
} else {
this.durationInMicroSec = 0;
}
}

public Duration getDuration() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,8 @@ private void validateTransportRequestTimelineDirect(String diagnostics) {
assertThat(diagnostics).contains("\"eventName\":\"transitTime\"");
assertThat(diagnostics).contains("\"eventName\":\"received\"");
assertThat(diagnostics).contains("\"eventName\":\"completed\"");
assertThat(diagnostics).contains("\"startTimeUTC\"");
assertThat(diagnostics).contains("\"durationInMicroSec\"");
}

private void validateJson(String jsonInString) {
Expand Down

0 comments on commit a856480

Please sign in to comment.