Skip to content

Commit

Permalink
MINOR: reduce sizeInBytes for percentiles metrics (apache#8835)
Browse files Browse the repository at this point in the history
Reviewers: Matthias J. Sax <[email protected]>, Guozhang Wang <[email protected]>, John Roesler <[email protected]>
  • Loading branch information
ableegoldman authored Jun 11, 2020
1 parent a6ca7ad commit 5f7b07b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -534,12 +534,12 @@ public void shouldPinLargerValuesToMax() {
@Test
public void testPercentilesWithRandomNumbersAndLinearBucketing() {
long seed = new Random().nextLong();
int sizeInBytes = 1000 * 1000; // 1MB
int sizeInBytes = 100 * 1000; // 100kB
long maximumValue = 1000 * 24 * 60 * 60 * 1000L; // if values are ms, max is 1000 days

try {
Random prng = new Random(seed);
int numberOfValues = 5000 + prng.nextInt(10_000); // ranges is [5000, 15000]
int numberOfValues = 5000 + prng.nextInt(10_000); // range is [5000, 15000]

Percentiles percs = new Percentiles(sizeInBytes,
maximumValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public int hashCode() {
public static final String RATE_DESCRIPTION_PREFIX = "The average number of ";
public static final String RATE_DESCRIPTION_SUFFIX = " per second";

private static final int PERCENTILES_SIZE_IN_BYTES = 1000 * 1000; // 1 MB
private static final int PERCENTILES_SIZE_IN_BYTES = 100 * 1000; // 100 kB
private static double MAXIMUM_E2E_LATENCY = 10 * 24 * 60 * 60 * 1000d; // maximum latency is 10 days; values above that will be pinned

public StreamsMetricsImpl(final Metrics metrics, final String clientId, final String builtInMetricsVersion) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,10 @@ public void shouldRecordE2ELatencyPercentiles() {
task.maybeRecordE2ELatency(0L, sourceNode);
}

assertEquals((double) p99Metric.metricValue(), 99d, 5.0);
assertEquals((double) p90Metric.metricValue(), 90d, 5.0);
final double expectedAccuracy = 0.25d; // Make sure it's accurate to within 25% of the expected value

assertEquals((double) p99Metric.metricValue(), 99d, 99 * expectedAccuracy);
assertEquals((double) p90Metric.metricValue(), 90d, 90 * expectedAccuracy);
}

@Test
Expand Down

0 comments on commit 5f7b07b

Please sign in to comment.