public static BundleDistribution bundleProcessingThreadDistribution(
      String shortId, MetricName name) {
    return new BundleProcessingThreadDistribution(shortId, name);
  }
@Test
  public void testAccurateBundleDistributionWithMutations() throws Exception {
    Map<String, ByteString> report = new HashMap<>();
    BundleDistribution bundleDistribution =
        Metrics.bundleProcessingThreadDistribution(TEST_ID, TEST_NAME);

    bundleDistribution.update(7);
    bundleDistribution.updateIntermediateMonitoringData(report);
    assertEquals(
        report,
        Collections.singletonMap(
            TEST_ID,
            MonitoringInfoEncodings.encodeInt64Distribution(DistributionData.singleton(7))));
    report.clear();

    bundleDistribution.updateIntermediateMonitoringData(report);
    assertEquals(report, Collections.emptyMap());

    bundleDistribution.update(5, 2, 2, 3);
    bundleDistribution.updateIntermediateMonitoringData(report);
    assertEquals(
        report,
        Collections.singletonMap(
            TEST_ID,
            MonitoringInfoEncodings.encodeInt64Distribution(DistributionData.create(12, 3, 2, 7))));
    report.clear();

    // Test re-use of the metrics after reset
    bundleDistribution.reset();
    bundleDistribution.update(7);
    bundleDistribution.updateIntermediateMonitoringData(report);
    assertEquals(
        report,
        Collections.singletonMap(
            TEST_ID,
            MonitoringInfoEncodings.encodeInt64Distribution(DistributionData.singleton(7))));
    report.clear();

    bundleDistribution.updateIntermediateMonitoringData(report);
    assertEquals(report, Collections.emptyMap());

    bundleDistribution.update(5, 2, 2, 3);
    bundleDistribution.updateIntermediateMonitoringData(report);
    assertEquals(
        report,
        Collections.singletonMap(
            TEST_ID,
            MonitoringInfoEncodings.encodeInt64Distribution(DistributionData.create(12, 3, 2, 7))));
  }