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

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

Reply via email to