Skip to content

Commit

Permalink
Calculate first response metrics from sent time #491
Browse files Browse the repository at this point in the history
Latency collection calculates firstResponse latency using sent time as reference. First response latency reflects the time between sending and receiving (processing) the first chunk of data for the command.

Previously firstResponse latency was calculated between first response time and command completion.
  • Loading branch information
mp911de committed Mar 20, 2017
1 parent b616b5a commit 7063839
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ private void recordLatency(WithLatency withLatency, ProtocolKeyword commandType)
if (withLatency != null && clientResources.commandLatencyCollector().isEnabled() && channel != null
&& remote() != null) {

long firstResponseLatency = nanoTime() - withLatency.getFirstResponse();
long firstResponseLatency = withLatency.getSent() - withLatency.getFirstResponse();
long completionLatency = nanoTime() - withLatency.getSent();

clientResources.commandLatencyCollector().recordCommandLatency(local(), remote(), commandType, firstResponseLatency,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ public void verifyMetrics() {
assertThat(metrics.getFirstResponse().getMax()).isBetween(290000L, 310000L);
assertThat(metrics.getCompletion().getPercentiles()).containsKey(50.0d);

assertThat(metrics.getFirstResponse().getPercentiles().get(50d)).isLessThanOrEqualTo(
metrics.getCompletion().getPercentiles().get(50d));

assertThat(metrics.getTimeUnit()).isEqualTo(MICROSECONDS);

assertThat(sut.retrieveMetrics()).isEmpty();
Expand Down

0 comments on commit 7063839

Please sign in to comment.