steffenvan commented on code in PR #1182:
URL: https://github.com/apache/jackrabbit-oak/pull/1182#discussion_r1386131023


##########
oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/importer/IndexImporter.java:
##########
@@ -465,19 +475,31 @@ interface IndexImporterStepExecutor {
     }
 
     void runWithRetry(int maxRetries, IndexImportState indexImportState, 
IndexImporterStepExecutor step) throws CommitFailedException, IOException {
+        String indexImportPhaseName = indexImportState == null ? "null" : 
indexImportState.toString();
         int count = 1;
         Stopwatch start = Stopwatch.createStarted();
         while (count <= maxRetries) {
-            LOG.info("IndexImporterStepExecutor:{}, count:{}", 
indexImportState, count);
-            LOG.info("[TASK:{}:START]", indexImportState);
+            LOG.info("IndexImporterStepExecutor:{}, count:{}", 
indexImportPhaseName, count);
+            LOG.info("[TASK:{}:START]", indexImportPhaseName);
             try {
                 step.execute();
-                LOG.info("[TASK:{}:END] Metrics: {}", indexImportState,
+                long durationSeconds = start.elapsed(TimeUnit.SECONDS);
+                LOG.info("[TASK:{}:END] Metrics: {}", indexImportPhaseName,
                         MetricsFormatter.newBuilder()
                                 .add("duration", 
FormattingUtils.formatToSeconds(start))
-                                .add("durationSeconds", 
start.elapsed(TimeUnit.SECONDS))
+                                .add("durationSeconds", durationSeconds)
                                 .build()
                 );
+
+                String name = "oak_indexer_import_" + 
indexImportPhaseName.toLowerCase() + "_duration_seconds";
+                CounterStats metric = statisticsProvider.getCounterStats(name, 
StatsOptions.METRICS_ONLY);
+                LOG.debug("Adding metric: {} {}", name, durationSeconds);

Review Comment:
   In `MetricUtils.java` I see the same logic of resetting the counter if it's 
not 0 from the start. Could be refactored to one function. 



-- 
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: dev-unsubscr...@jackrabbit.apache.org

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

Reply via email to