jojochuang commented on code in PR #8764: URL: https://github.com/apache/ozone/pull/8764#discussion_r2199364733
########## hadoop-hdds/rocksdb-checkpoint-differ/src/main/java/org/apache/ozone/rocksdiff/SSTFilePruningMetrics.java: ########## @@ -0,0 +1,131 @@ +/* + * 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.ozone.rocksdiff; + +import org.apache.hadoop.metrics2.MetricsCollector; +import org.apache.hadoop.metrics2.MetricsRecordBuilder; +import org.apache.hadoop.metrics2.MetricsSource; +import org.apache.hadoop.metrics2.annotation.Metric; +import org.apache.hadoop.metrics2.annotation.Metrics; +import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem; +import org.apache.hadoop.metrics2.lib.MetricsRegistry; +import org.apache.hadoop.metrics2.lib.MutableCounterLong; +import org.apache.hadoop.metrics2.lib.MutableGaugeLong; +import org.apache.hadoop.ozone.OzoneConsts; + +/** + * Class contains metrics for monitoring SST file pruning operations in RocksDBCheckpointDiffer. + */ +@Metrics(about = "SST File Pruning Metrics", context = OzoneConsts.OZONE) +public final class SSTFilePruningMetrics implements MetricsSource { + + public static final String METRICS_SOURCE_NAME = SSTFilePruningMetrics.class.getSimpleName(); + private MetricsRegistry registry; + + /* + * Pruning Throughput Metrics. + */ + @Metric("Total no. of SST files pruned") + private MutableCounterLong filesPrunedTotal; + @Metric("No. of SST files pruned in the last batch") + private MutableGaugeLong filesPrunedLast; + @Metric("Total no. of SST files removed") + private MutableCounterLong filesRemovedTotal; Review Comment: filesSkippedTotal would make more sense ########## hadoop-hdds/rocksdb-checkpoint-differ/src/main/java/org/apache/ozone/rocksdiff/SSTFilePruningMetrics.java: ########## @@ -0,0 +1,131 @@ +/* + * 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.ozone.rocksdiff; + +import org.apache.hadoop.metrics2.MetricsCollector; +import org.apache.hadoop.metrics2.MetricsRecordBuilder; +import org.apache.hadoop.metrics2.MetricsSource; +import org.apache.hadoop.metrics2.annotation.Metric; +import org.apache.hadoop.metrics2.annotation.Metrics; +import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem; +import org.apache.hadoop.metrics2.lib.MetricsRegistry; +import org.apache.hadoop.metrics2.lib.MutableCounterLong; +import org.apache.hadoop.metrics2.lib.MutableGaugeLong; +import org.apache.hadoop.ozone.OzoneConsts; + +/** + * Class contains metrics for monitoring SST file pruning operations in RocksDBCheckpointDiffer. + */ +@Metrics(about = "SST File Pruning Metrics", context = OzoneConsts.OZONE) +public final class SSTFilePruningMetrics implements MetricsSource { + + public static final String METRICS_SOURCE_NAME = SSTFilePruningMetrics.class.getSimpleName(); + private MetricsRegistry registry; + + /* + * Pruning Throughput Metrics. + */ + @Metric("Total no. of SST files pruned") + private MutableCounterLong filesPrunedTotal; + @Metric("No. of SST files pruned in the last batch") + private MutableGaugeLong filesPrunedLast; + @Metric("Total no. of SST files removed") + private MutableCounterLong filesRemovedTotal; + @Metric("Total no. of compactions processed") + private MutableCounterLong compactionsProcessed; + @Metric("No. of pending pruning jobs in queue") + private MutableGaugeLong pruneQueueSize; + + /* + * Pruning failure Metrics. + */ + @Metric("No. of pruning job failures") + private MutableCounterLong pruningFailures; + + private SSTFilePruningMetrics() { + this.registry = new MetricsRegistry(METRICS_SOURCE_NAME); + } + + /** + * Creates and returns SSTFilePruningMetrics instance. + * + * @return SSTFilePruningMetrics + */ + public static SSTFilePruningMetrics create() { + return DefaultMetricsSystem.instance().register(METRICS_SOURCE_NAME, "SST File Pruning Metrics", Review Comment: it seems there can be more than one RocksDBCheckpointDifferHolder, and therefore more than one SSTFilePruningMetrics instances. In which case, the unRegister() could cause resource leak -- when two SSTFilePruningMetrics are created, the first one registered to DefaultMetricsSystem is replaced by the second reference. In unRegister(), only the second one will be unregistered, and the first one leaks. ########## hadoop-hdds/rocksdb-checkpoint-differ/src/main/java/org/apache/ozone/rocksdiff/SSTFilePruningMetrics.java: ########## @@ -0,0 +1,131 @@ +/* + * 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.ozone.rocksdiff; + +import org.apache.hadoop.metrics2.MetricsCollector; +import org.apache.hadoop.metrics2.MetricsRecordBuilder; +import org.apache.hadoop.metrics2.MetricsSource; +import org.apache.hadoop.metrics2.annotation.Metric; +import org.apache.hadoop.metrics2.annotation.Metrics; +import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem; +import org.apache.hadoop.metrics2.lib.MetricsRegistry; +import org.apache.hadoop.metrics2.lib.MutableCounterLong; +import org.apache.hadoop.metrics2.lib.MutableGaugeLong; +import org.apache.hadoop.ozone.OzoneConsts; + +/** + * Class contains metrics for monitoring SST file pruning operations in RocksDBCheckpointDiffer. + */ +@Metrics(about = "SST File Pruning Metrics", context = OzoneConsts.OZONE) +public final class SSTFilePruningMetrics implements MetricsSource { + + public static final String METRICS_SOURCE_NAME = SSTFilePruningMetrics.class.getSimpleName(); + private MetricsRegistry registry; + + /* + * Pruning Throughput Metrics. + */ + @Metric("Total no. of SST files pruned") + private MutableCounterLong filesPrunedTotal; + @Metric("No. of SST files pruned in the last batch") + private MutableGaugeLong filesPrunedLast; + @Metric("Total no. of SST files removed") + private MutableCounterLong filesRemovedTotal; + @Metric("Total no. of compactions processed") + private MutableCounterLong compactionsProcessed; + @Metric("No. of pending pruning jobs in queue") + private MutableGaugeLong pruneQueueSize; + + /* + * Pruning failure Metrics. + */ + @Metric("No. of pruning job failures") + private MutableCounterLong pruningFailures; + + private SSTFilePruningMetrics() { + this.registry = new MetricsRegistry(METRICS_SOURCE_NAME); + } + + /** + * Creates and returns SSTFilePruningMetrics instance. + * + * @return SSTFilePruningMetrics + */ + public static SSTFilePruningMetrics create() { + return DefaultMetricsSystem.instance().register(METRICS_SOURCE_NAME, "SST File Pruning Metrics", Review Comment: The easiest solution is to associate the instance with a unique name. Check out the example made by Google Gemini: https://github.com/jojochuang/ozone/commit/51c32f70a77dfc28acd23463201eb7c4e2f9566e -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
