sk0x50 commented on code in PR #7428: URL: https://github.com/apache/ignite-3/pull/7428#discussion_r2727707871
########## modules/table/src/main/java/org/apache/ignite/internal/table/distributed/GlobalPartitionTableStatsMetricSource.java: ########## @@ -0,0 +1,79 @@ +/* + * 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.table.distributed; + +import static org.apache.ignite.internal.table.distributed.PartitionTableStatsMetricSource.METRIC_PENDING_WRITE_INTENTS; + +import java.util.function.LongSupplier; +import org.apache.ignite.internal.metrics.MetricSet; +import org.apache.ignite.internal.metrics.MetricSetBuilder; +import org.apache.ignite.internal.metrics.MetricSource; +import org.jetbrains.annotations.Nullable; + +/** + * Global metrics related to table partition statistics. + * + * <p>This source provides node-level aggregated statistics across all local table partitions. + */ +public class GlobalPartitionTableStatsMetricSource implements MetricSource { Review Comment: I would suggest using `TransactionMetricsSource` instead of creating a new one. The total number of write intents relates to transactions, IMHO, so I think it is better to add a new metric to the existing source. ########## modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java: ########## @@ -1648,59 +1661,97 @@ private PartitionUpdateHandlers createPartitionUpdateHandlers( PartitionModificationCounter modificationCounter = partitionModificationCounterFactory.create(partSizeSupplier, table::stalenessConfiguration, table.tableId(), partitionId); - registerPartitionModificationCounterMetrics(table, partitionId, modificationCounter); - StorageUpdateHandler storageUpdateHandler = new StorageUpdateHandler( partitionId, partitionDataStorage, indexUpdateHandler, replicationConfiguration, modificationCounter ); + storageUpdateHandler.start(onNodeRecovery); + registerPartitionTableStatsMetrics(table, partitionId, modificationCounter, storageUpdateHandler::getPendingRowCount); + return new PartitionUpdateHandlers(storageUpdateHandler, indexUpdateHandler, gcUpdateHandler); } - private void registerPartitionModificationCounterMetrics( + private void registerPartitionTableStatsMetrics( TableViewInternal table, int partitionId, - PartitionModificationCounter counter + PartitionModificationCounter counter, + LongSupplier pendingWriteIntentSupplier ) { - PartitionModificationCounterMetricSource metricSource = - new PartitionModificationCounterMetricSource(table.tableId(), partitionId); + PartitionTableStatsMetricSource metricSource = + new PartitionTableStatsMetricSource(table.tableId(), partitionId); metricSource.addMetric(new LongGauge( - PartitionModificationCounterMetricSource.METRIC_COUNTER, + METRIC_COUNTER, "The value of the volatile counter of partition modifications. " + "This value is used to determine staleness of the related SQL statistics.", counter::value )); metricSource.addMetric(new LongGauge( - PartitionModificationCounterMetricSource.METRIC_NEXT_MILESTONE, + METRIC_NEXT_MILESTONE, "The value of the next milestone for the number of partition modifications. " + "This value is used to determine staleness of the related SQL statistics.", counter::nextMilestone )); metricSource.addMetric(new LongGauge( - PartitionModificationCounterMetricSource.METRIC_LAST_MILESTONE_TIMESTAMP, + METRIC_LAST_MILESTONE_TIMESTAMP, "The timestamp value representing the commit time of the last modification operation that " + "reached the milestone. This value is used to determine staleness of the related SQL statistics.", () -> counter.lastMilestoneTimestamp().longValue() )); + metricSource.addMetric(new LongGauge( Review Comment: IMHO, this pattern is not correct. Typically, all metrics should be created within the corresponding metric source; adding new metrics from a "random" location looks odd to me. -- 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]
