tibrewalpratik17 commented on code in PR #13991:
URL: https://github.com/apache/pinot/pull/13991#discussion_r1760938266


##########
pinot-common/src/test/java/org/apache/pinot/common/metrics/AbstractMetricsTest.java:
##########
@@ -108,4 +112,154 @@ public void testMultipleGauges() {
     controllerMetrics.removeGauge(metricName2);
     
Assert.assertTrue(controllerMetrics.getMetricsRegistry().allMetrics().isEmpty());
   }
+
+  /**
+   * Creates and initializes a concrete instance of {@link AbstractMetrics} 
(in this case, a {@code ControllerMetrics}).
+   * @return a {@code ControllerMetrics} suitable for testing {@code 
AbstractMetrics} APIs
+   */
+  private static ControllerMetrics buildTestMetrics() {
+    PinotConfiguration pinotConfiguration = new PinotConfiguration();
+    pinotConfiguration.setProperty(CONFIG_OF_METRICS_FACTORY_CLASS_NAME,
+        "org.apache.pinot.plugin.metrics.yammer.YammerMetricsFactory");
+    PinotMetricUtils.init(pinotConfiguration);
+    return new ControllerMetrics(new YammerMetricsRegistry());
+  }
+
+  /**
+   * Tests the {@link AbstractMetrics} APIs relating to query phases
+   */
+  @Test
+  public void testQueryPhases() {
+    final ControllerMetrics testMetrics = buildTestMetrics();
+    final MetricsInspector inspector = new 
MetricsInspector(testMetrics.getMetricsRegistry());
+
+    // Establish dummy values to be used in the test
+    final AbstractMetrics.QueryPhase testPhase = () -> "testPhase";
+    Assert.assertEquals(testPhase.getDescription(), "");
+    final String testTableName = "tbl_testQueryPhases";
+    final String testTableName2 = "tbl2_testQueryPhases";
+
+    // Add a phase timing, check for correctness
+    testMetrics.addPhaseTiming(testTableName, testPhase, 1, TimeUnit.SECONDS);
+    final MetricName tbl1Metric = inspector.lastMetric();
+    Assert.assertEquals(inspector.getTimer(tbl1Metric).sum(), 1000);
+
+    // Add to the existing timer, using different API

Review Comment:
   nit: we can add in comment that this value is in nanos



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to