rpuch commented on code in PR #7269: URL: https://github.com/apache/ignite-3/pull/7269#discussion_r2639422769
########## modules/partition-replicator/src/main/java/org/apache/ignite/internal/partition/replicator/raft/snapshot/metrics/RaftSnapshotsMetricsSource.java: ########## @@ -0,0 +1,297 @@ +/* + * 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.partition.replicator.raft.snapshot.metrics; + +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.IntSupplier; +import org.apache.ignite.internal.metrics.AbstractMetricSource; +import org.apache.ignite.internal.metrics.IntGauge; +import org.apache.ignite.internal.metrics.Metric; +import org.apache.ignite.internal.partition.replicator.raft.snapshot.metrics.RaftSnapshotsMetricsSource.Holder; + +/** + * Metric source that exposes counters related to Raft snapshots lifecycle for partition replicator. + * + * <p>The source is registered under the name {@code raft.snapshots}. It maintains the number of currently + * running incoming and outgoing snapshots and per-phase counters for the installation of incoming snapshots. + * These counters are intended to help understand where time is spent during snapshot installation and + * whether there are any bottlenecks (for example, waiting for catalog, loading multi-versioned data, etc.). + */ +public class RaftSnapshotsMetricsSource extends AbstractMetricSource<Holder> { + private final AtomicInteger totalIncomingSnapshotsCounter = new AtomicInteger(); + + private final AtomicInteger snapshotsLoadingMetaCounter = new AtomicInteger(); + + private final AtomicInteger snapshotsWaitingCatalogCounter = new AtomicInteger(); + + private final AtomicInteger snapshotsPreparingStoragesCounter = new AtomicInteger(); + + private final AtomicInteger snapshotsPreparingIndexForBuildCounter = new AtomicInteger(); + + private final AtomicInteger snapshotsLoadingMvDataCounter = new AtomicInteger(); + + private final AtomicInteger snapshotsLoadingTxMetaCounter = new AtomicInteger(); + + private final AtomicInteger totalOutgoingSnapshotsCounter = new AtomicInteger(); + + /** + * Creates a new metric source with the name {@code raft.snapshots}. + */ + public RaftSnapshotsMetricsSource() { + super("raft.snapshots"); + } + + @Override + protected Holder createHolder() { + return new Holder( + totalIncomingSnapshotsCounter::get, + snapshotsLoadingMetaCounter::get, + snapshotsWaitingCatalogCounter::get, + snapshotsPreparingStoragesCounter::get, + snapshotsPreparingIndexForBuildCounter::get, + snapshotsLoadingMvDataCounter::get, + snapshotsLoadingTxMetaCounter::get, + totalOutgoingSnapshotsCounter::get + ); + } + + /** + * Marks the start of an incoming snapshot installation. + * Increments the {@code TotalIncomingSnapshots} counter. Review Comment: The method name is about starting an incoming snapshot. The fact that internally it updates a metric (which is indeed a public API) is the internal detail. I guess either it should not be mentioned at all, or the method name should tell that it increases the metric, not its javadoc -- 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]
