test_class.file: misc/metrics-extensions/modules/ballerina-metrics-extension/src/test/java/org/ballerinalang/observe/metrics/extension/defaultimpl/RollingHistogramTest.java
test_class.identifier: RollingHistogramTest
test_case.body: @Test
      public void testRollingHistogram() {
          final AtomicInteger currentTime = new AtomicInteger(0);
          Clock clock = mock(Clock.class);
          when(clock.getCurrentTime()).then(invocationOnMock -> currentTime.get());
          Assert.assertEquals(clock.getCurrentTime(), 0);
  
          double[] percentiles = new double[]{0.0, 0.5, 0.75, 0.9, 0.98, 0.99, 0.999, 1.0};
          RollingHistogram histogram = new RollingHistogram(clock, StatisticConfig.builder()
                  .percentiles(percentiles)
                  .expiry(Duration.ofSeconds(4)).buckets(4).build());
  
          histogram.record(10);
          histogram.record(20);
          Snapshot snapshot = histogram.getSnapshot();
          Assert.assertEquals(percentileValue(snapshot, 0.0), 10.0, 1.0);
          Assert.assertEquals(percentileValue(snapshot, 1.0), 20.0, 1.0);
          Assert.assertEquals(snapshot.getMin(), 10.0, 1.0);
          Assert.assertEquals(snapshot.getMax(), 20.0, 1.0);
  
          currentTime.addAndGet(900);
          Assert.assertEquals(clock.getCurrentTime(), 900);
  
          histogram.record(30);
          histogram.record(40);
  
          snapshot = histogram.getSnapshot();
          Assert.assertEquals(percentileValue(snapshot, 0.0), 10.0, 1.0);
          Assert.assertEquals(percentileValue(snapshot, 1.0), 40.0, 1.0);
          Assert.assertEquals(snapshot.getMin(), 10.0, 1.0);
          Assert.assertEquals(snapshot.getMax(), 40.0, 1.0);
  
          currentTime.addAndGet(99);
          Assert.assertEquals(clock.getCurrentTime(), 999);
  
          histogram.record(9);
          histogram.record(60);
  
          snapshot = histogram.getSnapshot();
          Assert.assertEquals(percentileValue(snapshot, 0.0), 9.0, 1.0);
          Assert.assertEquals(percentileValue(snapshot, 1.0), 60.0, 1.0);
          Assert.assertEquals(snapshot.getMin(), 9.0, 1.0);
          Assert.assertEquals(snapshot.getMax(), 60.0, 1.0);
  
          currentTime.addAndGet(1);
          Assert.assertEquals(clock.getCurrentTime(), 1000);
  
          histogram.record(12);
          histogram.record(70);
          snapshot = histogram.getSnapshot();
          Assert.assertEquals(percentileValue(snapshot, 0.0), 9.0, 1.0);
          Assert.assertEquals(percentileValue(snapshot, 1.0), 70.0, 1.0);
          Assert.assertEquals(snapshot.getMin(), 9.0, 1.0);
          Assert.assertEquals(snapshot.getMax(), 70.0, 1.0);
  
          currentTime.addAndGet(1001);
          Assert.assertEquals(clock.getCurrentTime(), 2001);
  
          histogram.record(13);
          histogram.record(80);
  
          snapshot = histogram.getSnapshot();
          Assert.assertEquals(snapshot.getMin(), 9.0, 1.0);
          Assert.assertEquals(snapshot.getMax(), 80.0, 1.0);
          Assert.assertEquals(percentileValue(snapshot, 0.0), 9.0, 1.0);
          Assert.assertEquals(percentileValue(snapshot, 1.0), 80.0, 1.0);
  
          currentTime.addAndGet(1000);
          Assert.assertEquals(clock.getCurrentTime(), 3001);
  
          snapshot = histogram.getSnapshot();
          Assert.assertEquals(percentileValue(snapshot, 0.0), 9.0, 1.0);
          Assert.assertEquals(percentileValue(snapshot, 1.0), 80.0, 1.0);
          Assert.assertEquals(snapshot.getMin(), 9.0, 1.0);
          Assert.assertEquals(snapshot.getMax(), 80.0, 1.0);
  
          currentTime.addAndGet(999);
          Assert.assertEquals(clock.getCurrentTime(), 4000);
  
          snapshot = histogram.getSnapshot();
          Assert.assertEquals(percentileValue(snapshot, 0.0), 12.0, 1.0);
          Assert.assertEquals(percentileValue(snapshot, 1.0), 80.0, 1.0);
          Assert.assertEquals(snapshot.getMin(), 12.0, 1.0);
          Assert.assertEquals(snapshot.getMax(), 80.0, 1.0);
  
          histogram.record(1);
          histogram.record(200);
  
          snapshot = histogram.getSnapshot();
          Assert.assertEquals(percentileValue(snapshot, 0.0), 1.0, 1.0);
          Assert.assertEquals(percentileValue(snapshot, 1.0), 200.0, 1.0);
          Assert.assertEquals(snapshot.getMin(), 1.0, 1.0);
          Assert.assertEquals(snapshot.getMax(), 200.0, 1.0);
  
          currentTime.addAndGet(10000);
          Assert.assertEquals(clock.getCurrentTime(), 14000);
  
          snapshot = histogram.getSnapshot();
          Assert.assertEquals(percentileValue(snapshot, 0.0), 0.0, 0.0);
          Assert.assertEquals(percentileValue(snapshot, 1.0), 0.0, 0.0);
          Assert.assertEquals(snapshot.getMin(), 0.0, 1.0);
          Assert.assertEquals(snapshot.getMax(), 0.0, 1.0);
  
          histogram.record(3);
  
          currentTime.addAndGet(3999);
          Assert.assertEquals(clock.getCurrentTime(), 17999);
  
          snapshot = histogram.getSnapshot();
          Assert.assertEquals(percentileValue(snapshot, 0.0), 3.0, 1.0);
          Assert.assertEquals(percentileValue(snapshot, 1.0), 3.0, 1.0);
          Assert.assertEquals(snapshot.getMin(), 3.0, 1.0);
          Assert.assertEquals(snapshot.getMax(), 3.0, 1.0);
  
          currentTime.addAndGet(1);
          Assert.assertEquals(clock.getCurrentTime(), 18000);
  
          snapshot = histogram.getSnapshot();
          Assert.assertEquals(percentileValue(snapshot, 0.0), 0.0, 0.0);
          Assert.assertEquals(percentileValue(snapshot, 1.0), 0.0, 0.0);
          Assert.assertEquals(snapshot.getMin(), 0.0, 1.0);
          Assert.assertEquals(snapshot.getMax(), 0.0, 1.0);
      }
test_case.class_method_signature: RollingHistogramTest.testRollingHistogram()
test_case.full_signature: @Test public void testRollingHistogram()
test_case.identifier: testRollingHistogram
test_case.invocations: mock then when getCurrentTime get assertEquals getCurrentTime build buckets expiry percentiles builder ofSeconds record record getSnapshot assertEquals percentileValue assertEquals percentileValue assertEquals getMin assertEquals getMax addAndGet assertEquals getCurrentTime record record getSnapshot assertEquals percentileValue assertEquals percentileValue assertEquals getMin assertEquals getMax addAndGet assertEquals getCurrentTime record record getSnapshot assertEquals percentileValue assertEquals percentileValue assertEquals getMin assertEquals getMax addAndGet assertEquals getCurrentTime record record getSnapshot assertEquals percentileValue assertEquals percentileValue assertEquals getMin assertEquals getMax addAndGet assertEquals getCurrentTime record record getSnapshot assertEquals getMin assertEquals getMax assertEquals percentileValue assertEquals percentileValue addAndGet assertEquals getCurrentTime getSnapshot assertEquals percentileValue assertEquals percentileValue assertEquals getMin assertEquals getMax addAndGet assertEquals getCurrentTime getSnapshot assertEquals percentileValue assertEquals percentileValue assertEquals getMin assertEquals getMax record record getSnapshot assertEquals percentileValue assertEquals percentileValue assertEquals getMin assertEquals getMax addAndGet assertEquals getCurrentTime getSnapshot assertEquals percentileValue assertEquals percentileValue assertEquals getMin assertEquals getMax record addAndGet assertEquals getCurrentTime getSnapshot assertEquals percentileValue assertEquals percentileValue assertEquals getMin assertEquals getMax addAndGet assertEquals getCurrentTime getSnapshot assertEquals percentileValue assertEquals percentileValue assertEquals getMin assertEquals getMax
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testRollingHistogram()
focal_class.declarator: clock
focal_class.modifier: private final
focal_class.original_string: private final Clock clock;
focal_class.type: Clock
focal_class.var_name: clock
focal_class.declarator: statisticConfig
focal_class.modifier: private final
focal_class.original_string: private final StatisticConfig statisticConfig;
focal_class.type: StatisticConfig
focal_class.var_name: statisticConfig
focal_class.declarator: ringBuffer
focal_class.modifier: private final
focal_class.original_string: private final DoubleRecorder[] ringBuffer;
focal_class.type: DoubleRecorder[]
focal_class.var_name: ringBuffer
focal_class.declarator: currentBucket
focal_class.modifier: private
focal_class.original_string: private int currentBucket;
focal_class.type: int
focal_class.var_name: currentBucket
focal_class.declarator: lastRotateTimestampMillis
focal_class.modifier: private volatile
focal_class.original_string: private volatile long lastRotateTimestampMillis;
focal_class.type: long
focal_class.var_name: lastRotateTimestampMillis
focal_class.declarator: durationBetweenRotatesMillis
focal_class.modifier: private final
focal_class.original_string: private final long durationBetweenRotatesMillis;
focal_class.type: long
focal_class.var_name: durationBetweenRotatesMillis
focal_class.declarator: intervalHistogram
focal_class.modifier: private final
focal_class.original_string: private final DoubleHistogram intervalHistogram;
focal_class.type: DoubleHistogram
focal_class.var_name: intervalHistogram
focal_class.declarator: accumulatedHistogram
focal_class.modifier: private
focal_class.original_string: private DoubleHistogram accumulatedHistogram;
focal_class.type: DoubleHistogram
focal_class.var_name: accumulatedHistogram
focal_class.declarator: rotatingUpdater =
              AtomicIntegerFieldUpdater.newUpdater(RollingHistogram.class, "rotating")
focal_class.modifier: private static final
focal_class.original_string: private static final AtomicIntegerFieldUpdater<RollingHistogram> rotatingUpdater =
              AtomicIntegerFieldUpdater.newUpdater(RollingHistogram.class, "rotating");
focal_class.type: AtomicIntegerFieldUpdater<RollingHistogram>
focal_class.var_name: rotatingUpdater
focal_class.declarator: rotating
focal_class.modifier: private volatile
focal_class.original_string: private volatile int rotating;
focal_class.type: int
focal_class.var_name: rotating
focal_class.declarator: accumulatedHistogramStale
focal_class.modifier: private volatile
focal_class.original_string: private volatile boolean accumulatedHistogramStale;
focal_class.type: boolean
focal_class.var_name: accumulatedHistogramStale
focal_class.file: misc/metrics-extensions/modules/ballerina-metrics-extension/src/main/java/org/ballerinalang/observe/metrics/extension/defaultimpl/RollingHistogram.java
focal_class.identifier: RollingHistogram
focal_class.class_method_signature: RollingHistogram.RollingHistogram(Clock clock, StatisticConfig statisticConfig)
focal_class.full_signature: public  RollingHistogram(Clock clock, StatisticConfig statisticConfig)
focal_class.identifier: RollingHistogram
focal_class.modifiers: public
focal_class.parameters: (Clock clock, StatisticConfig statisticConfig)
focal_class.signature:  RollingHistogram(Clock clock, StatisticConfig statisticConfig)
focal_class.class_method_signature: RollingHistogram.record(double value)
focal_class.full_signature: public void record(double value)
focal_class.identifier: record
focal_class.modifiers: public
focal_class.parameters: (double value)
focal_class.return: void
focal_class.signature: void record(double value)
focal_class.class_method_signature: RollingHistogram.rotate()
focal_class.full_signature: private void rotate()
focal_class.identifier: rotate
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void rotate()
focal_class.class_method_signature: RollingHistogram.getStatisticConfig()
focal_class.full_signature: public StatisticConfig getStatisticConfig()
focal_class.identifier: getStatisticConfig
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: StatisticConfig
focal_class.signature: StatisticConfig getStatisticConfig()
focal_class.class_method_signature: RollingHistogram.getSnapshot()
focal_class.full_signature: public Snapshot getSnapshot()
focal_class.identifier: getSnapshot
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Snapshot
focal_class.signature: Snapshot getSnapshot()
focal_class.class_method_signature: RollingHistogram.accumulateIfStale()
focal_class.full_signature: private void accumulateIfStale()
focal_class.identifier: accumulateIfStale
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void accumulateIfStale()
focal_class.class_method_signature: RollingHistogram.accumulate()
focal_class.full_signature: private void accumulate()
focal_class.identifier: accumulate
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void accumulate()
focal_class.class_method_signature: RollingHistogram.currentHistogram()
focal_class.full_signature: private DoubleRecorder currentHistogram()
focal_class.identifier: currentHistogram
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: DoubleRecorder
focal_class.signature: DoubleRecorder currentHistogram()
focal_method.body: public RollingHistogram(Clock clock, StatisticConfig statisticConfig) {
          this.clock = clock;
          this.statisticConfig = statisticConfig;
          int ageBuckets = (int) statisticConfig.getBuckets();
          ringBuffer = new DoubleRecorder[ageBuckets];
          for (int i = 0; i < ageBuckets; i++) {
              ringBuffer[i] = new DoubleRecorder(statisticConfig.getPercentilePrecision());
          }
          this.currentBucket = 0;
          this.lastRotateTimestampMillis = clock.getCurrentTime();
          this.durationBetweenRotatesMillis = statisticConfig.getTimeWindow().toMillis() / ageBuckets;
          intervalHistogram = new DoubleHistogram(statisticConfig.getPercentilePrecision());
          accumulatedHistogram = new DoubleHistogram(statisticConfig.getPercentilePrecision());
      }
focal_method.class_method_signature: RollingHistogram.RollingHistogram(Clock clock, StatisticConfig statisticConfig)
focal_method.full_signature: public  RollingHistogram(Clock clock, StatisticConfig statisticConfig)
focal_method.identifier: RollingHistogram
focal_method.modifiers: public
focal_method.parameters: (Clock clock, StatisticConfig statisticConfig)
focal_method.signature:  RollingHistogram(Clock clock, StatisticConfig statisticConfig)