Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdanfox committed Feb 18, 2020
1 parent 57b1733 commit a63dd26
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,17 +194,20 @@ public void onFailure(Throwable throwable) {
long numGlobalResponses = MetricNames.globalResponses(simulation.taggedMetrics())
.getCount();
long leaked = numGlobalResponses
- MetricNames.bodyClose(simulation.taggedMetrics()).getCount();
- MetricNames.responseClose(simulation.taggedMetrics())
.getCount();
return ImmutableBenchmarkResult.builder()
.clientHistogram(clientMetrics.response(SimulationUtils.SERVICE_NAME).getSnapshot())
.clientHistogram(clientMetrics
.response(SimulationUtils.SERVICE_NAME)
.getSnapshot())
.endTime(Duration.ofNanos(simulation.clock().read()))
.statusCodes(statusCodes)
.successPercentage(
Math.round(statusCodes.getOrDefault("200", 0) * 1000d / requestsStarted[0]) / 10d)
.numSent(requestsStarted[0])
.numReceived(responsesReceived[0])
.numGlobalResponses(numGlobalResponses)
.bodiesLeaked(leaked)
.responsesLeaked(leaked)
.build();
},
MoreExecutors.directExecutor());
Expand Down Expand Up @@ -240,8 +243,8 @@ interface BenchmarkResult {
/** How many responses were issued in total across all servers. */
long numGlobalResponses();

/** How many response bodies were never closed. */
long bodiesLeaked();
/** How many responses were never closed. */
long responsesLeaked();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
import com.palantir.tritium.metrics.registry.TaggedMetricRegistry;

final class MetricNames {
/** Counter incremented every time a {@code Response} body is closed. */
static Counter bodyClose(TaggedMetricRegistry reg) {
return reg.counter(MetricName.builder().safeName("bodyClose").build());
/** Counter incremented every time a {@code Response} is closed. */
static Counter responseClose(TaggedMetricRegistry reg) {
return reg.counter(MetricName.builder().safeName("responseClose").build());
}

/** Counter for how many responses are issued across all servers. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public Map<String, List<String>> headers() {

@Override
public void close() {
MetricNames.bodyClose(registry).inc();
MetricNames.responseClose(registry).inc();
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,13 +441,13 @@ public void after() throws IOException {

SimulationMetricsReporter.png(
pngPath, activeRequests, simulation.metricsReporter().chart(Pattern.compile("request.*count"))
// simulation.metrics().chart(Pattern.compile("(bodyClose|globalResponses)"))
// simulation.metrics().chart(Pattern.compile("(responseClose|globalResponses)"))
);
log.info("Generated {} ({} ms)", pngPath, sw.elapsed(TimeUnit.MILLISECONDS));
}

assertThat(result.bodiesLeaked())
.describedAs("There should be no unclosed response bodies")
assertThat(result.responsesLeaked())
.describedAs("There should be no unclosed responses")
.isZero();
}

Expand Down

0 comments on commit a63dd26

Please sign in to comment.