vmeka2020 commented on a change in pull request #1231:
URL: https://github.com/apache/phoenix/pull/1231#discussion_r724584773



##########
File path: 
phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixTableLevelMetricsIT.java
##########
@@ -1148,13 +1195,156 @@ private static void assertMetricValue(Metric m, 
MetricType checkType, long compa
         }
     }
 
+    @Test
+    public void testHistogramMetricsForMutations() throws Exception {
+        String tableName = generateUniqueName();
+        // Reset table level metrics to capture histogram metrics for upsert.
+        try (Connection conn =  getConnFromTestDriver()) {
+            createTableAndInsertValues(tableName, true, true, 10, true, conn, 
false);
+        }
+        // Metrics will be reset after creation of table so below we will get 
latency
+        // just for upsert queries.
+        // Since we are recording latency histograms after every 
executeMutation method and
+        // since we are not batch upserting, it will record histogram event 
after every upsert.
+        assertHistogramMetricsForMutations(tableName, true, 1, 1, true);
+
+        // Reset table histograms as well as global metrics
+        PhoenixRuntime.clearTableLevelMetrics();
+        PhoenixMetricsIT.resetGlobalMetrics();
+        try (Connection connection = getConnFromTestDriver();
+                Statement statement = connection.createStatement()) {
+            String delete = "DELETE FROM " + tableName;
+            statement.execute(delete);
+            connection.commit();
+        }
+        // Verify metrics for delete mutations
+        assertHistogramMetricsForMutations(tableName, false, 1, 1, true);
+        PhoenixRuntime.clearTableLevelMetrics();
+    }
+
+    @Test
+    public void testHistogramMetricsForMutationsAutoCommitTrue() throws 
Exception {
+        String tableName = generateUniqueName();
+        // Reset table level metrics to capture histogram metrics for upsert.
+        try (Connection conn =  getConnFromTestDriver()) {
+            conn.setAutoCommit(true);
+            createTableAndInsertValues(tableName, true, true, 10, false, conn, 
false);
+        }
+        // Metrics will be reset after creation of table so below we will get 
latency
+        // just for upsert queries.
+        // Since we are recording latency histograms after every 
executeMutation method and
+        // since we are not batch upserting, it will record histogram event 
after every upsert.
+        assertHistogramMetricsForMutations(tableName, true, 10, 10, false);
+
+        // Reset table histograms as well as global metrics
+        PhoenixRuntime.clearTableLevelMetrics();
+        PhoenixMetricsIT.resetGlobalMetrics();
+        try (Connection connection = getConnFromTestDriver();
+                Statement statement = connection.createStatement()) {
+            connection.setAutoCommit(true);
+            String delete = "DELETE FROM " + tableName;
+            statement.execute(delete);
+        }
+        // Verify metrics for delete mutations. We won't get any data point for
+        // size histogram since delete happened on server side using 
ServerSelectDeleteMutationPlan.

Review comment:
       Find the HBase server-side calls to get the data back to Phoenix. 




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to