You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "Phillippko (via GitHub)" <gi...@apache.org> on 2026/03/06 08:47:13 UTC

[PR] WIP x2 [ignite-3]

Phillippko opened a new pull request, #7722:
URL: https://github.com/apache/ignite-3/pull/7722

   https://issues.apache.org/jira/browse/IGNITE-27573


-- 
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: notifications-unsubscribe@ignite.apache.org

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


Re: [PR] IGNITE-27573 Adapt jraft node metrics to ignite metric framework [ignite-3]

Posted by "Cyrill (via GitHub)" <gi...@apache.org>.
Cyrill commented on code in PR #7722:
URL: https://github.com/apache/ignite-3/pull/7722#discussion_r2979893903


##########
modules/raft/src/main/java/org/apache/ignite/raft/jraft/RaftGroupService.java:
##########
@@ -68,18 +71,21 @@ public class RaftGroupService {
      * @param serverId Server id.
      * @param nodeOptions Node options.
      * @param rpcServer RPC server.
+     * @param metricManager

Review Comment:
   parameter without  description 



-- 
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: notifications-unsubscribe@ignite.apache.org

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


Re: [PR] IGNITE-27573 Adapt jraft node metrics to ignite metric framework [ignite-3]

Posted by "Cyrill (via GitHub)" <gi...@apache.org>.
Cyrill commented on code in PR #7722:
URL: https://github.com/apache/ignite-3/pull/7722#discussion_r2979937979


##########
modules/raft/src/test/java/org/apache/ignite/internal/metrics/sources/NodeMetricSourceTest.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.metrics.sources;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.util.HashSet;
+import java.util.Set;
+import org.apache.ignite.internal.metrics.MetricSet;
+import org.apache.ignite.internal.testframework.BaseIgniteAbstractTest;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests for raft node metrics.
+ */
+public class NodeMetricSourceTest extends BaseIgniteAbstractTest {
+    private static final String GROUP_ID = "test_group";
+
+    @Test
+    void testMetricSourceName() {
+        var metricSource = new NodeMetricSource(GROUP_ID);
+
+        assertThat(metricSource.name(), is("raft.node." + GROUP_ID));
+    }
+
+    @Test
+    void testMetricNames() {
+        var metricSource = new NodeMetricSource(GROUP_ID);
+
+        MetricSet set = metricSource.enable();
+
+        assertThat(set, is(notNullValue()));
+
+        Set<String> expectedMetrics = Set.of(
+                "OverloadCount",
+                "HandleAppendEntriesDuration",
+                "HeartbeatRequestTime",

Review Comment:
   looks like we have a confusion regarding metrics naming. I suppose better have  Duration everywhere, not Time



-- 
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: notifications-unsubscribe@ignite.apache.org

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


Re: [PR] IGNITE-27573 Adapt jraft node metrics to ignite metric framework [ignite-3]

Posted by "alievmirza (via GitHub)" <gi...@apache.org>.
alievmirza commented on code in PR #7722:
URL: https://github.com/apache/ignite-3/pull/7722#discussion_r2958861697


##########
modules/raft/src/main/java/org/apache/ignite/raft/jraft/core/FSMCallerImpl.java:
##########
@@ -69,29 +70,28 @@ public class FSMCallerImpl implements FSMCaller {
 
     private static final IgniteLogger LOG = Loggers.forClass(FSMCallerImpl.class);
 
+    private final MetricManager metricManager;
+
     /**
      * Task type
      */
     public enum TaskType {
-        IDLE, //
-        COMMITTED, //
-        SNAPSHOT_SAVE, //
-        SNAPSHOT_LOAD, //
-        LEADER_STOP, //
-        LEADER_START, //
-        START_FOLLOWING, //
-        STOP_FOLLOWING, //
-        SHUTDOWN, //
-        FLUSH, //
-        ERROR;
-
-        private String metricName;
-
-        public String metricName() {
-            if (this.metricName == null) {
-                this.metricName = "fsm-" + name().toLowerCase().replaceAll("_", "-");
-            }
-            return this.metricName;
+        IDLE ("IdleDuration"),

Review Comment:
   These are FSMCaller task types, so they have nothing in common with "...Duration". Why did you name them this way?



-- 
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: notifications-unsubscribe@ignite.apache.org

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


Re: [PR] IGNITE-27573 Adapt jraft node metrics to ignite metric framework [ignite-3]

Posted by "Phillippko (via GitHub)" <gi...@apache.org>.
Phillippko commented on code in PR #7722:
URL: https://github.com/apache/ignite-3/pull/7722#discussion_r2980158676


##########
modules/raft/src/main/java/org/apache/ignite/internal/metrics/sources/FsmCallerMetricSource.java:
##########
@@ -52,54 +51,87 @@ protected Holder createHolder() {
     /**
      * Called on FSM commit.
      *
-     * @param time Duration of the commit operation.
+     * @param duration Duration of the commit operation.
      */
-    public void onFsmCommit(long time) {
+    public void onFsmCommit(long duration) {
         Holder holder = holder();
 
         if (holder != null) {
-            holder.lastCommitTime.value(time);
+            holder.commitTime.add(duration);
         }
     }
 
     /**
      * Called on applying tasks.
      *
-     * @param time Duration of the apply operation.
+     * @param duration Duration of the apply operation.
      * @param size Number of tasks applied.
      */
-    public void onApplyTasks(long time, long size) {
+    public void onApplyTasks(long duration, long size) {
         Holder holder = holder();
 
         if (holder != null) {
-            holder.lastApplyTasksTime.value(time);
+            holder.applyTasksTime.add(duration);
             holder.applyTasksSize.add(size);
         }
     }
 
+    /**
+     * Called on applying task.
+     *
+     * @param type Type of the applied task.
+     * @param duration Duration of the apply operation.
+     * */
+    public void onApplyTask(TaskType type, long duration) {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.taskDurations.get(type).add(duration);
+        }
+    }
+
     /** Metric holder for FSM caller metrics. */
     static class Holder implements AbstractMetricSource.Holder<Holder> {
+        private static final long[] HISTOGRAM_BUCKETS =
+                {10, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000};
+
         private final DistributionMetric applyTasksSize = new DistributionMetric(
                 "ApplyTasksSize",
                 "Sizes of applied tasks batches",
                 new long[] {10, 20, 30, 40, 50}
         );
 
-        private final AtomicLongMetric lastApplyTasksTime = new AtomicLongMetric("ApplyTasksTime", "Time to apply tasks");
+        private final DistributionMetric applyTasksTime = new DistributionMetric(
+                "ApplyTasksTime",
+                "Duration of applying tasks in milliseconds",
+                HISTOGRAM_BUCKETS
+        );
 
-        private final AtomicLongMetric lastCommitTime = new AtomicLongMetric("CommitTime", "Time to apply tasks");
+        private final DistributionMetric commitTime = new DistributionMetric(
+                "CommitTime",
+                "Duration of committing in milliseconds",
+                HISTOGRAM_BUCKETS
+        );
 
         private final List<Metric> metrics;
 
+        private final HashMap<TaskType, DistributionMetric> taskDurations = new HashMap<>();
+
         Holder() {
             metrics = new ArrayList<>();
 
             metrics.add(applyTasksSize);
-            metrics.add(lastApplyTasksTime);
-            metrics.add(lastCommitTime);
+            metrics.add(applyTasksTime);
+            metrics.add(commitTime);

Review Comment:
   Forgot to answer - we add metrics for TaskType dinamically



-- 
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: notifications-unsubscribe@ignite.apache.org

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


Re: [PR] IGNITE-27573 Adapt jraft node metrics to ignite metric framework [ignite-3]

Posted by "Phillippko (via GitHub)" <gi...@apache.org>.
Phillippko commented on code in PR #7722:
URL: https://github.com/apache/ignite-3/pull/7722#discussion_r2980256209


##########
modules/raft/src/main/java/org/apache/ignite/internal/metrics/sources/RaftMetricSource.java:
##########


Review Comment:
   Yeah, fixed it



-- 
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: notifications-unsubscribe@ignite.apache.org

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


Re: [PR] IGNITE-27573 Adapt jraft node metrics to ignite metric framework [ignite-3]

Posted by "alievmirza (via GitHub)" <gi...@apache.org>.
alievmirza commented on code in PR #7722:
URL: https://github.com/apache/ignite-3/pull/7722#discussion_r2958970644


##########
modules/raft/src/main/java/org/apache/ignite/internal/metrics/sources/NodeMetricSource.java:
##########
@@ -0,0 +1,272 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.metrics.sources;
+
+import java.util.List;
+import org.apache.ignite.internal.metrics.AbstractMetricSource;
+import org.apache.ignite.internal.metrics.AtomicLongMetric;
+import org.apache.ignite.internal.metrics.DistributionMetric;
+import org.apache.ignite.internal.metrics.Metric;
+
+/**
+ * Metrics of fsm caller.
+ */
+public class NodeMetricSource extends AbstractMetricSource<NodeMetricSource.Holder> {
+    public static final String SOURCE_NAME = "raft.node";
+
+    /**
+     * Constructor.
+     */
+    public NodeMetricSource(String groupId) {
+        super(sourceName(groupId), "Raft node metrics.", "nodes");
+    }
+
+    /**
+     * Returns a metric source name for the given group name.
+     *
+     * @param groupId Raft group id.
+     * @return Metric source name.
+     */
+    public static String sourceName(String groupId) {
+        return SOURCE_NAME + '.' + groupId;
+    }
+
+    @Override
+    protected Holder createHolder() {
+        return new Holder();
+    }
+
+    /**
+     * Called when a node apply queue overload is detected.
+     */
+    public void onOverload() {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.overloadCount.increment();
+        }
+    }
+
+    /**
+     * Called when append entries are handled.
+     *
+     * @param duration Duration of the operation.
+     * @param entriesCount Number of entries handled.
+     * @param success Whether the operation was successful.
+     */
+    public void onHandleAppendEntries(long duration, int entriesCount, boolean success) {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.handleAppendEntriesDuration.add(duration);
+            if (success) {
+                holder.appendEntriesBatchSize.add(entriesCount);
+            }
+        }
+    }
+
+    /**
+     * Called when a heartbeat request is handled.
+     *
+     * @param duration Duration of the operation.
+     */
+    public void onHandleHeartbeatRequest(long duration) {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.heartBeatRequestTime.add(duration);
+        }
+    }
+
+    /**
+     * Called when a request vote is handled.
+     *
+     * @param duration Duration of the operation.
+     */
+    public void onRequestVote(long duration) {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.requestVoteDuration.add(duration);
+        }
+    }
+
+    /**
+     * Called when a read request is handled.
+     *
+     * @param duration Duration of the operation.
+     * @param entriesCount Number of entries in the read request.
+     */
+    public void onHandleReadRequest(long duration, int entriesCount) {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.handleReadRequestDuration.add(duration);
+            holder.readRequestBatchSize.add(entriesCount);
+        }
+    }
+
+    /**
+     * Called when a get leader request is handled.
+     *
+     * @param duration Duration of the operation.
+     */
+    public void onHandleGetLeader(long duration) {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.handleGetLeaderDuration.add(duration);
+        }
+    }
+
+    /**
+     * Called when a pre-vote is handled.
+     *
+     * @param duration Duration of the operation.
+     */
+    public void onPreVote(long duration) {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.preVoteDuration.add(duration);
+        }
+    }
+
+    /**
+     * Called when an install snapshot request is handled.
+     *
+     * @param duration Duration of the operation.
+     */
+    public void onInstallSnapshot(long duration) {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.installSnapshotDuration.add(duration);
+        }
+    }
+
+    /**
+     * Called when a lock is blocked.
+     *
+     * @param blockedMs Duration of the lock being blocked in milliseconds.
+     */
+    public void onLockBlocked(long blockedMs) {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.lockBlockedCount.increment();
+            holder.lockBlockedDuration.add(blockedMs);
+        }
+    }
+
+    /** Metric holder for node metrics. */
+    static class Holder implements AbstractMetricSource.Holder<Holder> {
+        private static final long[] HISTOGRAM_BUCKETS =
+                {10, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000};
+
+        private final AtomicLongMetric overloadCount = new AtomicLongMetric(
+                "OverloadCount",
+                "The number of times when node impl was overloaded."
+        );
+
+        private final DistributionMetric handleAppendEntriesDuration = new DistributionMetric(
+                "HandleAppendEntriesDuration",
+                "Duration of handling append entries request in node impl in milliseconds",

Review Comment:
   Are these messages exposed to a user? In that case, what is node impl? Users know nothing internal naming



-- 
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: notifications-unsubscribe@ignite.apache.org

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


Re: [PR] IGNITE-27573 Adapt jraft node metrics to ignite metric framework [ignite-3]

Posted by "Cyrill (via GitHub)" <gi...@apache.org>.
Cyrill commented on code in PR #7722:
URL: https://github.com/apache/ignite-3/pull/7722#discussion_r2979884638


##########
modules/raft/src/main/java/org/apache/ignite/raft/jraft/JRaftUtils.java:
##########
@@ -25,7 +25,7 @@
 import java.util.concurrent.ThreadPoolExecutor;
 import org.apache.ignite.internal.logger.IgniteLogger;
 import org.apache.ignite.internal.logger.Loggers;
-import org.apache.ignite.internal.thread.IgniteThread;
+import org.apache.ignite.internal.metrics.MetricManager;import org.apache.ignite.internal.thread.IgniteThread;

Review Comment:
   formatting



-- 
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: notifications-unsubscribe@ignite.apache.org

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


Re: [PR] IGNITE-27573 Adapt jraft node metrics to ignite metric framework [ignite-3]

Posted by "Cyrill (via GitHub)" <gi...@apache.org>.
Cyrill commented on code in PR #7722:
URL: https://github.com/apache/ignite-3/pull/7722#discussion_r2979883504


##########
modules/raft/src/main/java/org/apache/ignite/raft/jraft/Node.java:
##########
@@ -17,10 +17,10 @@
 package org.apache.ignite.raft.jraft;
 
 import java.util.List;
+import org.apache.ignite.internal.metrics.sources.NodeMetricSource;
 import org.apache.ignite.raft.jraft.closure.ReadIndexClosure;
 import org.apache.ignite.raft.jraft.conf.Configuration;
-import org.apache.ignite.raft.jraft.core.NodeMetrics;
-import org.apache.ignite.raft.jraft.core.Replicator;
+import org.apache.ignite.raft.jraft.core.NodeMetrics;import org.apache.ignite.raft.jraft.core.Replicator;

Review Comment:
   formatting



-- 
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: notifications-unsubscribe@ignite.apache.org

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


Re: [PR] IGNITE-27573 Adapt jraft node metrics to ignite metric framework [ignite-3]

Posted by "Phillippko (via GitHub)" <gi...@apache.org>.
Phillippko commented on code in PR #7722:
URL: https://github.com/apache/ignite-3/pull/7722#discussion_r2980257791


##########
modules/raft/src/main/java/org/apache/ignite/internal/metrics/sources/RaftMetricSource.java:
##########
@@ -35,7 +35,9 @@
 public class RaftMetricSource implements MetricSource {
     public static final String SOURCE_NAME = "raft";
 
-    public static final String RAFT_GROUP_LEADERS = "groups.localLeadersCount";

Review Comment:
   you're right, changed back



-- 
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: notifications-unsubscribe@ignite.apache.org

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


Re: [PR] IGNITE-27573 Adapt jraft node metrics to ignite metric framework [ignite-3]

Posted by "Cyrill (via GitHub)" <gi...@apache.org>.
Cyrill commented on code in PR #7722:
URL: https://github.com/apache/ignite-3/pull/7722#discussion_r2979993966


##########
modules/raft/src/main/java/org/apache/ignite/internal/metrics/sources/RaftMetricSource.java:
##########


Review Comment:
   Not related to your pr, but how does it work? to 'disable' we set ENABLED=true. Looks utterly suspicious 



-- 
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: notifications-unsubscribe@ignite.apache.org

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


Re: [PR] IGNITE-27573 Adapt jraft node metrics to ignite metric framework [ignite-3]

Posted by "Cyrill (via GitHub)" <gi...@apache.org>.
Cyrill commented on code in PR #7722:
URL: https://github.com/apache/ignite-3/pull/7722#discussion_r2979921971


##########
modules/raft/src/main/java/org/apache/ignite/internal/metrics/sources/ReadOnlyServiceMetricSource.java:
##########
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.metrics.sources;
+
+import java.util.List;
+import org.apache.ignite.internal.metrics.AbstractMetricSource;
+import org.apache.ignite.internal.metrics.AtomicLongMetric;
+import org.apache.ignite.internal.metrics.DistributionMetric;
+import org.apache.ignite.internal.metrics.Metric;
+
+/**
+ * Metrics of read only service.
+ */
+public class ReadOnlyServiceMetricSource extends AbstractMetricSource<ReadOnlyServiceMetricSource.Holder> {
+    public static final String SOURCE_NAME = "raft.readonlyservice";
+
+    /**
+     * Constructor.
+     */
+    public ReadOnlyServiceMetricSource(String groupId) {
+        super(sourceName(groupId), "Read only service metrics.", "readOnlyServices");
+    }
+
+    private static String sourceName(String groupId) {
+        return SOURCE_NAME + '.' + groupId;
+    }
+
+    @Override
+    protected Holder createHolder() {
+        return new Holder();
+    }
+
+    /**
+     * Called when read index queue is overloaded.
+     */
+    public void onReadIndexOverload() {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.overloadTimes.increment();
+        }
+    }
+
+    /**
+     * Called when a read index operation completes.
+     *
+     * @param duration Duration of the read index operation.
+     */
+    public void onReadIndex(long duration) {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.indexReadDuration.add(duration);
+        }
+    }
+
+    /** Metric holder for read only service metrics. */
+    static class Holder implements AbstractMetricSource.Holder<Holder> {
+        private static final long[] HISTOGRAM_BUCKETS =

Review Comment:
   Shouldn't it be extracted to a  shared constant as it is used in more than one place? 



-- 
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: notifications-unsubscribe@ignite.apache.org

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


Re: [PR] IGNITE-27573 Adapt jraft node metrics to ignite metric framework [ignite-3]

Posted by "Cyrill (via GitHub)" <gi...@apache.org>.
Cyrill commented on code in PR #7722:
URL: https://github.com/apache/ignite-3/pull/7722#discussion_r2979900931


##########
modules/raft/src/main/java/org/apache/ignite/internal/metrics/sources/NodeMetricSource.java:
##########
@@ -0,0 +1,272 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.metrics.sources;
+
+import java.util.List;
+import org.apache.ignite.internal.metrics.AbstractMetricSource;
+import org.apache.ignite.internal.metrics.AtomicLongMetric;
+import org.apache.ignite.internal.metrics.DistributionMetric;
+import org.apache.ignite.internal.metrics.Metric;
+
+/**
+ * Metrics of fsm caller.

Review Comment:
   I suppose you had "Metrics of raft node" in mind.



-- 
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: notifications-unsubscribe@ignite.apache.org

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


Re: [PR] IGNITE-27573 Adapt jraft node metrics to ignite metric framework [ignite-3]

Posted by "Cyrill (via GitHub)" <gi...@apache.org>.
Cyrill commented on code in PR #7722:
URL: https://github.com/apache/ignite-3/pull/7722#discussion_r2979887990


##########
modules/raft/src/main/java/org/apache/ignite/internal/raft/server/impl/JraftServerImpl.java:
##########
@@ -162,6 +163,8 @@ public class JraftServerImpl implements RaftServer {
     /** The number of parallel raft groups starts. */
     private static final int SIMULTANEOUS_GROUP_START_PARALLELISM = Math.min(Utils.cpus() * 3, 25);
 
+    private final   MetricManager metricManager;

Review Comment:
   double space



-- 
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: notifications-unsubscribe@ignite.apache.org

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


Re: [PR] IGNITE-27573 Adapt jraft node metrics to ignite metric framework [ignite-3]

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #7722:
URL: https://github.com/apache/ignite-3/pull/7722#discussion_r2944872686


##########
modules/raft/src/main/java/org/apache/ignite/internal/metrics/sources/FsmCallerMetricSource.java:
##########
@@ -52,54 +51,87 @@ protected Holder createHolder() {
     /**
      * Called on FSM commit.
      *
-     * @param time Duration of the commit operation.
+     * @param duration Duration of the commit operation.
      */
-    public void onFsmCommit(long time) {
+    public void onFsmCommit(long duration) {
         Holder holder = holder();
 
         if (holder != null) {
-            holder.lastCommitTime.value(time);
+            holder.commitTime.add(duration);
         }
     }
 
     /**
      * Called on applying tasks.
      *
-     * @param time Duration of the apply operation.
+     * @param duration Duration of the apply operation.
      * @param size Number of tasks applied.
      */
-    public void onApplyTasks(long time, long size) {
+    public void onApplyTasks(long duration, long size) {
         Holder holder = holder();
 
         if (holder != null) {
-            holder.lastApplyTasksTime.value(time);
+            holder.applyTasksTime.add(duration);
             holder.applyTasksSize.add(size);
         }
     }
 
+    /**
+     * Called on applying task.
+     *
+     * @param type Type of the applied task.
+     * @param duration Duration of the apply operation.
+     * */
+    public void onApplyTask(TaskType type, long duration) {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.taskDurations.get(type).add(duration);
+        }
+    }
+
     /** Metric holder for FSM caller metrics. */
     static class Holder implements AbstractMetricSource.Holder<Holder> {
+        private static final long[] HISTOGRAM_BUCKETS =
+                {10, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000};
+
         private final DistributionMetric applyTasksSize = new DistributionMetric(
                 "ApplyTasksSize",
                 "Sizes of applied tasks batches",
                 new long[] {10, 20, 30, 40, 50}
         );
 
-        private final AtomicLongMetric lastApplyTasksTime = new AtomicLongMetric("ApplyTasksTime", "Time to apply tasks");
+        private final DistributionMetric applyTasksTime = new DistributionMetric(
+                "ApplyTasksTime",
+                "Duration of applying tasks in milliseconds",
+                HISTOGRAM_BUCKETS
+        );
 
-        private final AtomicLongMetric lastCommitTime = new AtomicLongMetric("CommitTime", "Time to apply tasks");
+        private final DistributionMetric commitTime = new DistributionMetric(
+                "CommitTime",
+                "Duration of committing in milliseconds",
+                HISTOGRAM_BUCKETS
+        );
 
         private final List<Metric> metrics;
 
+        private final HashMap<TaskType, DistributionMetric> taskDurations = new HashMap<>();
+
         Holder() {
             metrics = new ArrayList<>();
 
             metrics.add(applyTasksSize);
-            metrics.add(lastApplyTasksTime);
-            metrics.add(lastCommitTime);
+            metrics.add(applyTasksTime);
+            metrics.add(commitTime);

Review Comment:
   Could be `metrics = List.of(applyTasksSize, applyTasksTime, commitTime)`.
   
   I wonder why you decided to write it this way, for future extensibility? Will this list become dynamic in the near future?



##########
modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/CliIntegrationTest.java:
##########
@@ -382,10 +381,10 @@ public static MetricSource[] getExpectedNodeMetrics(Ignite ignite) {
                 new MetricSource().name("raft.snapshots").enabled(true),
                 new MetricSource().name("messaging").enabled(true),
                 new MetricSource().name("log.storage").enabled(true),
-                new MetricSource().name(THREAD_POOLS_METRICS_SOURCE_NAME + "striped.messaging.inbound.default").enabled(true),
-                new MetricSource().name(THREAD_POOLS_METRICS_SOURCE_NAME + "striped.messaging.inbound.deploymentunits").enabled(true),
-                new MetricSource().name(THREAD_POOLS_METRICS_SOURCE_NAME + "striped.messaging.inbound.scalecube").enabled(true),
-                new MetricSource().name(THREAD_POOLS_METRICS_SOURCE_NAME + "messaging.outbound").enabled(true)
+                new MetricSource().name("thread.pools.striped.messaging.inbound.default").enabled(true),

Review Comment:
   Would be nice to sort them alphabetically, but maybe that's too much to ask



##########
modules/raft/src/main/java/org/apache/ignite/internal/metrics/sources/LogManagerMetricSource.java:
##########
@@ -81,20 +82,25 @@ public void onAppendLogs(int entriesCount, int writtenSize, long duration) {
         if (holder != null) {
             holder.appendLogsCount.add(entriesCount);
             holder.appendLogsSize.add(writtenSize);
-            holder.lastAppendLogsDuration.value(duration);
+            holder.appendLogsDuration.add(duration);
         }
     }
 
     /** Metric holder for log manager metrics. */
     static class Holder implements AbstractMetricSource.Holder<Holder> {
-        private final AtomicLongMetric lastTruncateLogSuffixTime = new AtomicLongMetric(
+        private static final long[] HISTOGRAM_BUCKETS =
+                {10, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000};

Review Comment:
   Up to 500 thousands? Woooow, that's too much. Are these milliseconds, what will they measure?
   
   Some operations are better measured in microseconds, it has to be metric-dependent. Let's discuss these bounds separately



##########
modules/raft/src/main/java/org/apache/ignite/internal/metrics/sources/FsmCallerMetricSource.java:
##########
@@ -52,54 +51,87 @@ protected Holder createHolder() {
     /**
      * Called on FSM commit.
      *
-     * @param time Duration of the commit operation.
+     * @param duration Duration of the commit operation.
      */
-    public void onFsmCommit(long time) {
+    public void onFsmCommit(long duration) {
         Holder holder = holder();
 
         if (holder != null) {
-            holder.lastCommitTime.value(time);
+            holder.commitTime.add(duration);
         }
     }
 
     /**
      * Called on applying tasks.
      *
-     * @param time Duration of the apply operation.
+     * @param duration Duration of the apply operation.
      * @param size Number of tasks applied.
      */
-    public void onApplyTasks(long time, long size) {
+    public void onApplyTasks(long duration, long size) {
         Holder holder = holder();
 
         if (holder != null) {
-            holder.lastApplyTasksTime.value(time);
+            holder.applyTasksTime.add(duration);
             holder.applyTasksSize.add(size);
         }
     }
 
+    /**
+     * Called on applying task.
+     *
+     * @param type Type of the applied task.
+     * @param duration Duration of the apply operation.
+     * */
+    public void onApplyTask(TaskType type, long duration) {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.taskDurations.get(type).add(duration);
+        }
+    }
+
     /** Metric holder for FSM caller metrics. */
     static class Holder implements AbstractMetricSource.Holder<Holder> {
+        private static final long[] HISTOGRAM_BUCKETS =
+                {10, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000};
+
         private final DistributionMetric applyTasksSize = new DistributionMetric(
                 "ApplyTasksSize",
                 "Sizes of applied tasks batches",
                 new long[] {10, 20, 30, 40, 50}
         );
 
-        private final AtomicLongMetric lastApplyTasksTime = new AtomicLongMetric("ApplyTasksTime", "Time to apply tasks");
+        private final DistributionMetric applyTasksTime = new DistributionMetric(
+                "ApplyTasksTime",
+                "Duration of applying tasks in milliseconds",
+                HISTOGRAM_BUCKETS
+        );
 
-        private final AtomicLongMetric lastCommitTime = new AtomicLongMetric("CommitTime", "Time to apply tasks");
+        private final DistributionMetric commitTime = new DistributionMetric(
+                "CommitTime",
+                "Duration of committing in milliseconds",
+                HISTOGRAM_BUCKETS
+        );
 
         private final List<Metric> metrics;
 
+        private final HashMap<TaskType, DistributionMetric> taskDurations = new HashMap<>();

Review Comment:
   1. Type should be declared as `Map`, not `HashMap`. Why did you do this?
   2. Please use `EnumMap` for enums. A dedicated type of map is better than a universal one.



-- 
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: notifications-unsubscribe@ignite.apache.org

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


Re: [PR] IGNITE-27573 Adapt jraft node metrics to ignite metric framework [ignite-3]

Posted by "Cyrill (via GitHub)" <gi...@apache.org>.
Cyrill commented on code in PR #7722:
URL: https://github.com/apache/ignite-3/pull/7722#discussion_r2979890338


##########
modules/raft/src/main/java/org/apache/ignite/raft/jraft/core/NodeImpl.java:
##########
@@ -4277,7 +4288,7 @@ public Message handleInstallSnapshot(final InstallSnapshotRequest request, final
             return null;
         }
         finally {
-            this.metrics.recordLatency("install-snapshot", Utils.monotonicMs() - startMs);
+            this.metrics.onInstallSnapshot( Utils.monotonicMs() - startMs);

Review Comment:
   space



-- 
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: notifications-unsubscribe@ignite.apache.org

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


Re: [PR] IGNITE-27573 Adapt jraft node metrics to ignite metric framework [ignite-3]

Posted by "Cyrill (via GitHub)" <gi...@apache.org>.
Cyrill commented on code in PR #7722:
URL: https://github.com/apache/ignite-3/pull/7722#discussion_r2979913248


##########
modules/raft/src/main/java/org/apache/ignite/internal/metrics/sources/RaftMetricSource.java:
##########
@@ -35,7 +35,9 @@
 public class RaftMetricSource implements MetricSource {
     public static final String SOURCE_NAME = "raft";
 
-    public static final String RAFT_GROUP_LEADERS = "groups.localLeadersCount";

Review Comment:
   Sorry, I might be wrong here, but aren't metric names supposed to be maintained in a backward compatible way? Can we rename existing metrics?



-- 
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: notifications-unsubscribe@ignite.apache.org

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


Re: [PR] IGNITE-27573 Adapt jraft node metrics to ignite metric framework [ignite-3]

Posted by "Phillippko (via GitHub)" <gi...@apache.org>.
Phillippko commented on code in PR #7722:
URL: https://github.com/apache/ignite-3/pull/7722#discussion_r2980154990


##########
modules/raft/src/main/java/org/apache/ignite/raft/jraft/core/FSMCallerImpl.java:
##########
@@ -69,29 +70,28 @@ public class FSMCallerImpl implements FSMCaller {
 
     private static final IgniteLogger LOG = Loggers.forClass(FSMCallerImpl.class);
 
+    private final MetricManager metricManager;
+
     /**
      * Task type
      */
     public enum TaskType {
-        IDLE, //
-        COMMITTED, //
-        SNAPSHOT_SAVE, //
-        SNAPSHOT_LOAD, //
-        LEADER_STOP, //
-        LEADER_START, //
-        START_FOLLOWING, //
-        STOP_FOLLOWING, //
-        SHUTDOWN, //
-        FLUSH, //
-        ERROR;
-
-        private String metricName;
-
-        public String metricName() {
-            if (this.metricName == null) {
-                this.metricName = "fsm-" + name().toLowerCase().replaceAll("_", "-");
-            }
-            return this.metricName;
+        IDLE ("IdleDuration"),

Review Comment:
   It's metric name field, not task name



-- 
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: notifications-unsubscribe@ignite.apache.org

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


Re: [PR] IGNITE-27573 Adapt jraft node metrics to ignite metric framework [ignite-3]

Posted by "alievmirza (via GitHub)" <gi...@apache.org>.
alievmirza commented on code in PR #7722:
URL: https://github.com/apache/ignite-3/pull/7722#discussion_r2958970644


##########
modules/raft/src/main/java/org/apache/ignite/internal/metrics/sources/NodeMetricSource.java:
##########
@@ -0,0 +1,272 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.metrics.sources;
+
+import java.util.List;
+import org.apache.ignite.internal.metrics.AbstractMetricSource;
+import org.apache.ignite.internal.metrics.AtomicLongMetric;
+import org.apache.ignite.internal.metrics.DistributionMetric;
+import org.apache.ignite.internal.metrics.Metric;
+
+/**
+ * Metrics of fsm caller.
+ */
+public class NodeMetricSource extends AbstractMetricSource<NodeMetricSource.Holder> {
+    public static final String SOURCE_NAME = "raft.node";
+
+    /**
+     * Constructor.
+     */
+    public NodeMetricSource(String groupId) {
+        super(sourceName(groupId), "Raft node metrics.", "nodes");
+    }
+
+    /**
+     * Returns a metric source name for the given group name.
+     *
+     * @param groupId Raft group id.
+     * @return Metric source name.
+     */
+    public static String sourceName(String groupId) {
+        return SOURCE_NAME + '.' + groupId;
+    }
+
+    @Override
+    protected Holder createHolder() {
+        return new Holder();
+    }
+
+    /**
+     * Called when a node apply queue overload is detected.
+     */
+    public void onOverload() {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.overloadCount.increment();
+        }
+    }
+
+    /**
+     * Called when append entries are handled.
+     *
+     * @param duration Duration of the operation.
+     * @param entriesCount Number of entries handled.
+     * @param success Whether the operation was successful.
+     */
+    public void onHandleAppendEntries(long duration, int entriesCount, boolean success) {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.handleAppendEntriesDuration.add(duration);
+            if (success) {
+                holder.appendEntriesBatchSize.add(entriesCount);
+            }
+        }
+    }
+
+    /**
+     * Called when a heartbeat request is handled.
+     *
+     * @param duration Duration of the operation.
+     */
+    public void onHandleHeartbeatRequest(long duration) {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.heartBeatRequestTime.add(duration);
+        }
+    }
+
+    /**
+     * Called when a request vote is handled.
+     *
+     * @param duration Duration of the operation.
+     */
+    public void onRequestVote(long duration) {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.requestVoteDuration.add(duration);
+        }
+    }
+
+    /**
+     * Called when a read request is handled.
+     *
+     * @param duration Duration of the operation.
+     * @param entriesCount Number of entries in the read request.
+     */
+    public void onHandleReadRequest(long duration, int entriesCount) {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.handleReadRequestDuration.add(duration);
+            holder.readRequestBatchSize.add(entriesCount);
+        }
+    }
+
+    /**
+     * Called when a get leader request is handled.
+     *
+     * @param duration Duration of the operation.
+     */
+    public void onHandleGetLeader(long duration) {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.handleGetLeaderDuration.add(duration);
+        }
+    }
+
+    /**
+     * Called when a pre-vote is handled.
+     *
+     * @param duration Duration of the operation.
+     */
+    public void onPreVote(long duration) {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.preVoteDuration.add(duration);
+        }
+    }
+
+    /**
+     * Called when an install snapshot request is handled.
+     *
+     * @param duration Duration of the operation.
+     */
+    public void onInstallSnapshot(long duration) {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.installSnapshotDuration.add(duration);
+        }
+    }
+
+    /**
+     * Called when a lock is blocked.
+     *
+     * @param blockedMs Duration of the lock being blocked in milliseconds.
+     */
+    public void onLockBlocked(long blockedMs) {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.lockBlockedCount.increment();
+            holder.lockBlockedDuration.add(blockedMs);
+        }
+    }
+
+    /** Metric holder for node metrics. */
+    static class Holder implements AbstractMetricSource.Holder<Holder> {
+        private static final long[] HISTOGRAM_BUCKETS =
+                {10, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000};
+
+        private final AtomicLongMetric overloadCount = new AtomicLongMetric(
+                "OverloadCount",
+                "The number of times when node impl was overloaded."
+        );
+
+        private final DistributionMetric handleAppendEntriesDuration = new DistributionMetric(
+                "HandleAppendEntriesDuration",
+                "Duration of handling append entries request in node impl in milliseconds",

Review Comment:
   Are these messages exposed to a user? In that case, what is node impl? Users know nothing about internal naming



-- 
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: notifications-unsubscribe@ignite.apache.org

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


Re: [PR] IGNITE-27573 Adapt jraft node metrics to ignite metric framework [ignite-3]

Posted by "Phillippko (via GitHub)" <gi...@apache.org>.
Phillippko commented on code in PR #7722:
URL: https://github.com/apache/ignite-3/pull/7722#discussion_r2980144144


##########
modules/raft/src/main/java/org/apache/ignite/internal/metrics/sources/ReadOnlyServiceMetricSource.java:
##########
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.metrics.sources;
+
+import java.util.List;
+import org.apache.ignite.internal.metrics.AbstractMetricSource;
+import org.apache.ignite.internal.metrics.AtomicLongMetric;
+import org.apache.ignite.internal.metrics.DistributionMetric;
+import org.apache.ignite.internal.metrics.Metric;
+
+/**
+ * Metrics of read only service.
+ */
+public class ReadOnlyServiceMetricSource extends AbstractMetricSource<ReadOnlyServiceMetricSource.Holder> {
+    public static final String SOURCE_NAME = "raft.readonlyservice";
+
+    /**
+     * Constructor.
+     */
+    public ReadOnlyServiceMetricSource(String groupId) {
+        super(sourceName(groupId), "Read only service metrics.", "readOnlyServices");
+    }
+
+    private static String sourceName(String groupId) {
+        return SOURCE_NAME + '.' + groupId;
+    }
+
+    @Override
+    protected Holder createHolder() {
+        return new Holder();
+    }
+
+    /**
+     * Called when read index queue is overloaded.
+     */
+    public void onReadIndexOverload() {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.overloadTimes.increment();
+        }
+    }
+
+    /**
+     * Called when a read index operation completes.
+     *
+     * @param duration Duration of the read index operation.
+     */
+    public void onReadIndex(long duration) {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.indexReadDuration.add(duration);
+        }
+    }
+
+    /** Metric holder for read only service metrics. */
+    static class Holder implements AbstractMetricSource.Holder<Holder> {
+        private static final long[] HISTOGRAM_BUCKETS =

Review Comment:
   Buckets will be different for different metrics, exact borders for specific metrics will be discussed



-- 
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: notifications-unsubscribe@ignite.apache.org

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


Re: [PR] IGNITE-27573 Adapt jraft node metrics to ignite metric framework [ignite-3]

Posted by "Phillippko (via GitHub)" <gi...@apache.org>.
Phillippko commented on code in PR #7722:
URL: https://github.com/apache/ignite-3/pull/7722#discussion_r2980139569


##########
modules/raft/src/main/java/org/apache/ignite/raft/jraft/storage/impl/LocalRaftMetaStorage.java:
##########
@@ -127,9 +128,7 @@ private boolean save() {
         }
         finally {
             long cost = Utils.monotonicMs() - start;
-            if (this.nodeMetrics != null) {

Review Comment:
   yes



-- 
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: notifications-unsubscribe@ignite.apache.org

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


Re: [PR] IGNITE-27573 Adapt jraft node metrics to ignite metric framework [ignite-3]

Posted by "Phillippko (via GitHub)" <gi...@apache.org>.
Phillippko commented on code in PR #7722:
URL: https://github.com/apache/ignite-3/pull/7722#discussion_r2980135056


##########
modules/raft/src/main/java/org/apache/ignite/internal/metrics/sources/ReadOnlyServiceMetricSource.java:
##########
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.metrics.sources;
+
+import java.util.List;
+import org.apache.ignite.internal.metrics.AbstractMetricSource;
+import org.apache.ignite.internal.metrics.AtomicLongMetric;
+import org.apache.ignite.internal.metrics.DistributionMetric;
+import org.apache.ignite.internal.metrics.Metric;
+
+/**
+ * Metrics of read only service.
+ */
+public class ReadOnlyServiceMetricSource extends AbstractMetricSource<ReadOnlyServiceMetricSource.Holder> {
+    public static final String SOURCE_NAME = "raft.readonlyservice";
+
+    /**
+     * Constructor.
+     */
+    public ReadOnlyServiceMetricSource(String groupId) {
+        super(sourceName(groupId), "Read only service metrics.", "readOnlyServices");
+    }
+
+    private static String sourceName(String groupId) {
+        return SOURCE_NAME + '.' + groupId;
+    }
+
+    @Override
+    protected Holder createHolder() {
+        return new Holder();
+    }
+
+    /**
+     * Called when read index queue is overloaded.
+     */
+    public void onReadIndexOverload() {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.overloadTimes.increment();
+        }
+    }
+
+    /**
+     * Called when a read index operation completes.
+     *
+     * @param duration Duration of the read index operation.
+     */
+    public void onReadIndex(long duration) {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.indexReadDuration.add(duration);
+        }
+    }
+
+    /** Metric holder for read only service metrics. */
+    static class Holder implements AbstractMetricSource.Holder<Holder> {
+        private static final long[] HISTOGRAM_BUCKETS =
+                {10, 50, 100, 200, 500, 1000, 2000, 5000, 10000};
+
+        AtomicLongMetric overloadTimes = new AtomicLongMetric(

Review Comment:
   It's for different queues, readOnlyServiceQueue and applyQueue
   
   



-- 
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: notifications-unsubscribe@ignite.apache.org

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


Re: [PR] IGNITE-27573 Adapt jraft node metrics to ignite metric framework [ignite-3]

Posted by "Cyrill (via GitHub)" <gi...@apache.org>.
Cyrill commented on code in PR #7722:
URL: https://github.com/apache/ignite-3/pull/7722#discussion_r2979949037


##########
modules/raft/src/main/java/org/apache/ignite/internal/metrics/sources/ReadOnlyServiceMetricSource.java:
##########
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.metrics.sources;
+
+import java.util.List;
+import org.apache.ignite.internal.metrics.AbstractMetricSource;
+import org.apache.ignite.internal.metrics.AtomicLongMetric;
+import org.apache.ignite.internal.metrics.DistributionMetric;
+import org.apache.ignite.internal.metrics.Metric;
+
+/**
+ * Metrics of read only service.
+ */
+public class ReadOnlyServiceMetricSource extends AbstractMetricSource<ReadOnlyServiceMetricSource.Holder> {
+    public static final String SOURCE_NAME = "raft.readonlyservice";
+
+    /**
+     * Constructor.
+     */
+    public ReadOnlyServiceMetricSource(String groupId) {
+        super(sourceName(groupId), "Read only service metrics.", "readOnlyServices");
+    }
+
+    private static String sourceName(String groupId) {
+        return SOURCE_NAME + '.' + groupId;
+    }
+
+    @Override
+    protected Holder createHolder() {
+        return new Holder();
+    }
+
+    /**
+     * Called when read index queue is overloaded.
+     */
+    public void onReadIndexOverload() {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.overloadTimes.increment();
+        }
+    }
+
+    /**
+     * Called when a read index operation completes.
+     *
+     * @param duration Duration of the read index operation.
+     */
+    public void onReadIndex(long duration) {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.indexReadDuration.add(duration);
+        }
+    }
+
+    /** Metric holder for read only service metrics. */
+    static class Holder implements AbstractMetricSource.Holder<Holder> {
+        private static final long[] HISTOGRAM_BUCKETS =
+                {10, 50, 100, 200, 500, 1000, 2000, 5000, 10000};
+
+        AtomicLongMetric overloadTimes = new AtomicLongMetric(

Review Comment:
   Isn't it the same as OverloadCount in NodeMetricSource?



-- 
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: notifications-unsubscribe@ignite.apache.org

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


Re: [PR] IGNITE-27573 Adapt jraft node metrics to ignite metric framework [ignite-3]

Posted by "Cyrill (via GitHub)" <gi...@apache.org>.
Cyrill commented on code in PR #7722:
URL: https://github.com/apache/ignite-3/pull/7722#discussion_r2979927899


##########
modules/raft/src/main/java/org/apache/ignite/raft/jraft/storage/impl/LocalRaftMetaStorage.java:
##########
@@ -127,9 +128,7 @@ private boolean save() {
         }
         finally {
             long cost = Utils.monotonicMs() - start;
-            if (this.nodeMetrics != null) {

Review Comment:
   so it's never null now, right?



-- 
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: notifications-unsubscribe@ignite.apache.org

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


Re: [PR] IGNITE-27573 Adapt jraft node metrics to ignite metric framework [ignite-3]

Posted by "Cyrill (via GitHub)" <gi...@apache.org>.
Cyrill commented on code in PR #7722:
URL: https://github.com/apache/ignite-3/pull/7722#discussion_r2979868347


##########
modules/raft/src/main/java/org/apache/ignite/raft/jraft/core/FSMCallerImpl.java:
##########
@@ -69,29 +70,28 @@ public class FSMCallerImpl implements FSMCaller {
 
     private static final IgniteLogger LOG = Loggers.forClass(FSMCallerImpl.class);
 
+    private final MetricManager metricManager;
+
     /**
      * Task type
      */
     public enum TaskType {
-        IDLE, //
-        COMMITTED, //
-        SNAPSHOT_SAVE, //
-        SNAPSHOT_LOAD, //
-        LEADER_STOP, //
-        LEADER_START, //
-        START_FOLLOWING, //
-        STOP_FOLLOWING, //
-        SHUTDOWN, //
-        FLUSH, //
-        ERROR;
-
-        private String metricName;
-
-        public String metricName() {
-            if (this.metricName == null) {
-                this.metricName = "fsm-" + name().toLowerCase().replaceAll("_", "-");
-            }
-            return this.metricName;
+        IDLE ("IdleDuration"),
+        COMMITTED ("CommittedDuration"),
+        SNAPSHOT_SAVE ("SnapshotSaveDuration"),
+        SNAPSHOT_LOAD ("SnapshotLoadDuration"),
+        LEADER_STOP ("LeaderLoadDuration"),

Review Comment:
   LeaderStopDuration?



-- 
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: notifications-unsubscribe@ignite.apache.org

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


Re: [PR] IGNITE-27573 Adapt jraft node metrics to ignite metric framework [ignite-3]

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov merged PR #7722:
URL: https://github.com/apache/ignite-3/pull/7722


-- 
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: notifications-unsubscribe@ignite.apache.org

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


Re: [PR] IGNITE-27573 Adapt jraft node metrics to ignite metric framework [ignite-3]

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #7722:
URL: https://github.com/apache/ignite-3/pull/7722#discussion_r2940314746


##########
modules/raft/src/main/java/org/apache/ignite/internal/metrics/sources/LogManagerMetricSource.java:
##########
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.metrics.sources;
+
+import java.util.List;
+import org.apache.ignite.internal.metrics.AbstractMetricSource;
+import org.apache.ignite.internal.metrics.AtomicLongMetric;
+import org.apache.ignite.internal.metrics.Metric;
+
+/** Metrics of log manager. */
+public class LogManagerMetricSource extends AbstractMetricSource<LogManagerMetricSource.Holder> {
+    public static final String SOURCE_NAME = "raft.logmanager";
+
+    /**
+     * Constructor.
+     */
+    public LogManagerMetricSource(String groupId) {
+        super(sourceName(groupId));
+    }
+
+    private static String sourceName(String groupId) {
+        return SOURCE_NAME + '.' + groupId;
+    }
+
+    @Override
+    protected Holder createHolder() {
+        return new Holder();
+    }
+
+    /**
+     * Called when log suffix is truncated.
+     *
+     * @param duration Duration of the truncate operation.
+     */
+    public void onTruncateLogSuffix(long duration) {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.lastTruncateLogSuffixTime.value(duration);
+        }
+    }
+
+    /**
+     * Called when log prefix is truncated.
+     *
+     * @param duration Duration of the truncate operation.
+     */
+    public void onTruncateLogPrefix(long duration) {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.lastTruncateLogPrefixTime.value(duration);
+        }
+    }
+
+    /**
+     * Called when logs are appended.
+     *
+     * @param entriesCount Number of entries appended.
+     * @param writtenSize Written size in bytes.
+     * @param duration Duration of the append operation.
+     */
+    public void onAppendLogs(int entriesCount, int writtenSize, long duration) {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.appendLogsCount.add(entriesCount);
+            holder.appendLogsSize.add(writtenSize);
+            holder.lastAppendLogsDuration.value(duration);
+        }
+    }
+
+    /** Metric holder for log manager metrics. */
+    static class Holder implements AbstractMetricSource.Holder<Holder> {
+        private final AtomicLongMetric lastTruncateLogSuffixTime = new AtomicLongMetric(
+                "TruncateLogSuffixDuration",
+                "The last duration of truncating log suffix"

Review Comment:
   Applies to everything.
   
   What does this duration mean? Is it seconds, or minutes?
   
   The `Last` part is also not reflected in metric name, but it should, I think. Current name would make more sense for a distribution metric.
   
   Also, is `Last*` better than having a duration distribution? What would you prefer to see if you're debugging a strange cluster behavior?



##########
modules/raft/src/main/java/org/apache/ignite/internal/metrics/sources/FsmCallerMetricSource.java:
##########
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.metrics.sources;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.ignite.internal.metrics.AbstractMetricSource;
+import org.apache.ignite.internal.metrics.AtomicLongMetric;
+import org.apache.ignite.internal.metrics.DistributionMetric;
+import org.apache.ignite.internal.metrics.LongGauge;
+import org.apache.ignite.internal.metrics.Metric;
+import org.apache.ignite.raft.jraft.core.FSMCallerImpl;
+import org.apache.ignite.raft.jraft.core.FSMCallerImpl.TaskType;
+
+/**
+ * Metrics of FSM caller.
+ */
+public class FsmCallerMetricSource extends AbstractMetricSource<FsmCallerMetricSource.Holder> {
+    public static final String SOURCE_NAME = "raft.fsmcaller";
+
+    /**
+     * Constructor.
+     */
+    public FsmCallerMetricSource(String groupId) {
+        super(sourceName(groupId));
+    }
+
+    private static String sourceName(String groupId) {
+        return SOURCE_NAME + '.' + groupId;
+    }
+
+    @Override
+    protected Holder createHolder() {
+        return new Holder();
+    }
+
+    /**
+     * Called on FSM commit.
+     *
+     * @param time Duration of the commit operation.
+     */
+    public void onFsmCommit(long time) {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.lastCommitTime.value(time);
+        }
+    }
+
+    /**
+     * Called on applying tasks.
+     *
+     * @param time Duration of the apply operation.
+     * @param size Number of tasks applied.
+     */
+    public void onApplyTasks(long time, long size) {
+        Holder holder = holder();
+
+        if (holder != null) {
+            holder.lastApplyTasksTime.value(time);
+            holder.applyTasksSize.add(size);
+        }
+    }
+
+    /** Metric holder for FSM caller metrics. */
+    static class Holder implements AbstractMetricSource.Holder<Holder> {
+        private final DistributionMetric applyTasksSize = new DistributionMetric(
+                "ApplyTasksSize",
+                "Sizes of applied tasks batches",
+                new long[] {10, 20, 30, 40, 50}
+        );
+
+        private final AtomicLongMetric lastApplyTasksTime = new AtomicLongMetric("ApplyTasksTime", "Time to apply tasks");
+
+        private final AtomicLongMetric lastCommitTime = new AtomicLongMetric("CommitTime", "Time to apply tasks");
+
+        private final List<Metric> metrics;
+
+        Holder() {
+            metrics = new ArrayList<>();
+
+            metrics.add(applyTasksSize);
+            metrics.add(lastApplyTasksTime);
+            metrics.add(lastCommitTime);
+
+            for (TaskType type : FSMCallerImpl.TaskType.values()) {
+                metrics.add(new LongGauge(type.metricName(), "Time to execute " + type.name() + " task", type::getApplyDuration));
+            }

Review Comment:
   Names like `IdleDuration` fit us better than `idle.Duration`. In other words, current naming system is inconsistent with what we already have, and looks weird in general. Please also get rid of underscores and use camel-case.



##########
modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/CliIntegrationTest.java:
##########
@@ -372,6 +342,64 @@ protected static void createAndPopulateTable() {
         );
     }
 
+    /** Returns all metric sources that are expected to be present on all nodes combined. */
+    public static MetricSource[] getExpectedClusterMetrics() {
+        Set<MetricSource> result = new HashSet<>();
+
+        for (var node : CLUSTER.nodes()) {
+            result.addAll(List.of(getExpectedNodeMetrics(node)));
+        }
+
+        return result.toArray(MetricSource[]::new);
+    }
+
+    /** Returns all metric sources that are expected to be present on a specific node. */
+    public static MetricSource[] getExpectedNodeMetrics(Ignite ignite) {
+        MetricSource[] commonMetrics = {new MetricSource().name("jvm").enabled(true),
+                new MetricSource().name("os").enabled(true),
+                new MetricSource().name("raft").enabled(true),
+                new MetricSource().name("metastorage").enabled(true),
+                new MetricSource().name("client.handler").enabled(true),
+                new MetricSource().name("sql.client").enabled(true),
+                new MetricSource().name("sql.plan.cache").enabled(true),
+                new MetricSource().name("sql.queries").enabled(true),
+                new MetricSource().name("storage.aipersist").enabled(true),
+                new MetricSource().name("storage.aipersist.default").enabled(true),
+                new MetricSource().name("storage.aipersist.default_aipersist").enabled(true),
+                new MetricSource().name("storage.aipersist.checkpoint").enabled(true),
+                new MetricSource().name("storage.aipersist.io").enabled(true),
+                new MetricSource().name("topology.cluster").enabled(true),
+                new MetricSource().name("topology.local").enabled(true),
+                new MetricSource().name("thread.pools.partitions-executor").enabled(true),
+                new MetricSource().name("thread.pools.sql-executor").enabled(true),
+                new MetricSource().name("thread.pools.sql-planning-executor").enabled(true),
+                new MetricSource().name("transactions").enabled(true),
+                new MetricSource().name("placement-driver").enabled(true),
+                new MetricSource().name("resource.vacuum").enabled(true),
+                new MetricSource().name("zones.Default").enabled(true),
+                new MetricSource().name("clock.service").enabled(true),
+                new MetricSource().name("index.builder").enabled(true),
+                new MetricSource().name("raft.snapshots").enabled(true),
+                new MetricSource().name("messaging").enabled(true),
+                new MetricSource().name("log.storage").enabled(true),
+                new MetricSource().name(THREAD_POOLS_METRICS_SOURCE_NAME + "striped.messaging.inbound.default").enabled(true),
+                new MetricSource().name(THREAD_POOLS_METRICS_SOURCE_NAME + "striped.messaging.inbound.deploymentunits").enabled(true),
+                new MetricSource().name(THREAD_POOLS_METRICS_SOURCE_NAME + "striped.messaging.inbound.scalecube").enabled(true),
+                new MetricSource().name(THREAD_POOLS_METRICS_SOURCE_NAME + "messaging.outbound").enabled(true)

Review Comment:
   Maybe we should inline these prefixes, every other metric source is an explicit string



-- 
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: notifications-unsubscribe@ignite.apache.org

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