avijayanhwx commented on a change in pull request #761: HDDS-3336. Metrics for 
Recon OzoneManager DB sync.
URL: https://github.com/apache/hadoop-ozone/pull/761#discussion_r403260751
 
 

 ##########
 File path: 
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/metrics/OzoneManagerSyncMetrics.java
 ##########
 @@ -0,0 +1,155 @@
+/**
+ * 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.hadoop.ozone.recon.metrics;
+
+import org.apache.hadoop.hdds.annotation.InterfaceAudience;
+import org.apache.hadoop.metrics2.MetricsSystem;
+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.MutableCounterLong;
+import org.apache.hadoop.metrics2.lib.MutableGaugeFloat;
+import org.apache.hadoop.metrics2.lib.MutableRate;
+import org.apache.hadoop.ozone.OzoneConsts;
+
+/**
+ * Class for tracking metrics related to Ozone manager sync operations.
+ */
+@InterfaceAudience.Private
+@Metrics(about = "Recon OzoneManagerSync Metrics", context = OzoneConsts.OZONE)
+public final class OzoneManagerSyncMetrics {
+
+  private static final String SOURCE_NAME =
+      OzoneManagerSyncMetrics.class.getSimpleName();
+
+  private OzoneManagerSyncMetrics() {
+  }
+
+  public static OzoneManagerSyncMetrics create() {
+    MetricsSystem ms = DefaultMetricsSystem.instance();
+    return ms.register(SOURCE_NAME,
+        "Recon Ozone Manager Sync Metrics",
+        new OzoneManagerSyncMetrics());
+  }
+
+  public void unRegister() {
+    MetricsSystem ms = DefaultMetricsSystem.instance();
 
 Review comment:
   @vivekratnavel That means I would have to move the  'MetricsSystem' variable 
into a class field. I don't think it is appropriate for the source to maintain 
a reference to the metrics system. Plus, this is not a costly operation. 
   
   Also, I have not made OzoneManagerSyncMetrics a singleton since we expect 
only one user of it. In the future, if we have more than usages for this class, 
we can move this to a singleton like we did for some other cases in OM and SCM.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: ozone-issues-h...@hadoop.apache.org

Reply via email to