tarun11Mavani commented on code in PR #16344:
URL: https://github.com/apache/pinot/pull/16344#discussion_r2284961997


##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/realtime/converter/RealtimeSegmentConverter.java:
##########
@@ -125,6 +164,34 @@ public void build(@Nullable SegmentVersion segmentVersion, 
@Nullable ServerMetri
     }
   }
 
+  /**
+   * Publishes detailed commit-time compaction metrics
+   */
+  private void publishCompactionMetrics(ServerMetrics serverMetrics, int 
preCompactionRowCount,
+      SegmentIndexCreationDriverImpl driver, long compactionStartTime) {
+    try {
+      int postCompactionRowCount = driver.getSegmentStats().getTotalDocCount();
+      long compactionProcessingTime = System.currentTimeMillis() - 
compactionStartTime;
+      int rowsRemoved = preCompactionRowCount - postCompactionRowCount;
+
+      // Publish basic row count metrics
+      serverMetrics.addMeteredTableValue(_tableName, 
ServerMeter.COMMIT_TIME_COMPACTION_ROWS_POST_COMPACTION,
+          postCompactionRowCount);
+      serverMetrics.addMeteredTableValue(_tableName, 
ServerMeter.COMMIT_TIME_COMPACTION_ROWS_REMOVED, rowsRemoved);
+      serverMetrics.addMeteredTableValue(_tableName, 
ServerMeter.COMMIT_TIME_COMPACTION_BUILD_TIME_MS,
+          compactionProcessingTime);
+
+      // Calculate and publish compaction ratio percentage (only if we had 
rows to compact)
+      if (preCompactionRowCount > 0) {
+        double compactionRatioPercent = (double) rowsRemoved / 
preCompactionRowCount * 100.0;
+        serverMetrics.setOrUpdateTableGauge(_tableName, 
ServerGauge.COMMIT_TIME_COMPACTION_RATIO_PERCENT,
+            (long) compactionRatioPercent);
+      }
+    } catch (Exception e) {
+      //no-op.

Review Comment:
   done



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to