  @Test
  void collectMetrics_WithMultipleCollects() {

    long startTime = testClock.now();
    LongValueRecorderSdk longMeasure = testSdk.longValueRecorderBuilder("testRecorder").build();
    BoundLongValueRecorder boundMeasure = longMeasure.bind(Labels.of("K", "V"));
    try {
      // Do some records using bounds and direct calls and bindings.
      longMeasure.record(12, Labels.empty());
      boundMeasure.record(123);
      longMeasure.record(-14, Labels.empty());
      // Advancing time here should not matter.
      testClock.advanceNanos(SECOND_NANOS);
      boundMeasure.record(321);
      longMeasure.record(-121, Labels.of("K", "V"));

      long firstCollect = testClock.now();
      List<MetricData> metricDataList = longMeasure.collectAll();
      assertThat(metricDataList).hasSize(1);
      MetricData metricData = metricDataList.get(0);
      assertThat(metricData.getPoints()).hasSize(2);
      assertThat(metricData.getPoints())
          .containsExactlyInAnyOrder(
              SummaryPoint.create(
                  startTime, firstCollect, Labels.empty(), 2, -2, valueAtPercentiles(-14, 12)),
              SummaryPoint.create(
                  startTime,
                  firstCollect,
                  Labels.of("K", "V"),
                  3,
                  323,
                  valueAtPercentiles(-121, 321)));

      // Repeat to prove we don't keep previous values.
      testClock.advanceNanos(SECOND_NANOS);
      boundMeasure.record(222);
      longMeasure.record(17, Labels.empty());

      long secondCollect = testClock.now();
      metricDataList = longMeasure.collectAll();
      assertThat(metricDataList).hasSize(1);
      metricData = metricDataList.get(0);
      assertThat(metricData.getPoints()).hasSize(2);
      assertThat(metricData.getPoints())
          .containsExactlyInAnyOrder(
              SummaryPoint.create(
                  startTime + SECOND_NANOS,
                  secondCollect,
                  Labels.empty(),
                  1,
                  17,
                  valueAtPercentiles(17, 17)),
              SummaryPoint.create(
                  startTime + SECOND_NANOS,
                  secondCollect,
                  Labels.of("K", "V"),
                  1,
                  222,
                  valueAtPercentiles(222, 222)));
    } finally {
      boundMeasure.unbind();
    }
  }