Extract ChronicleMapStoreMetrics to its own class file

Change-Id: Ie687d29c46a1000914a193aa2e6d55cf5438cce3
diff --git a/src/main/java/com/googlesource/gerrit/modules/cache/chroniclemap/ChronicleMapStore.java b/src/main/java/com/googlesource/gerrit/modules/cache/chroniclemap/ChronicleMapStore.java
index 4df1729..0419ca4 100644
--- a/src/main/java/com/googlesource/gerrit/modules/cache/chroniclemap/ChronicleMapStore.java
+++ b/src/main/java/com/googlesource/gerrit/modules/cache/chroniclemap/ChronicleMapStore.java
@@ -15,8 +15,6 @@
 package com.googlesource.gerrit.modules.cache.chroniclemap;
 
 import com.google.common.flogger.FluentLogger;
-import com.google.gerrit.metrics.Counter0;
-import com.google.gerrit.metrics.Description;
 import com.google.gerrit.metrics.MetricMaker;
 import java.io.File;
 import java.io.IOException;
@@ -328,61 +326,4 @@
   public boolean isOpen() {
     return store.isOpen();
   }
-
-  private static class ChronicleMapStoreMetrics {
-    private final String sanitizedName;
-    private final MetricMaker metricMaker;
-    private final String name;
-    private final Counter0 storePutFailures;
-
-    ChronicleMapStoreMetrics(String name, MetricMaker metricMaker) {
-      this.name = name;
-      this.sanitizedName = metricMaker.sanitizeMetricName(name);
-      this.metricMaker = metricMaker;
-
-      this.storePutFailures =
-          metricMaker.newCounter(
-              "cache/chroniclemap/store_put_failures_" + sanitizedName,
-              new Description(
-                      "The number of errors caught when inserting entries in chronicle-map store: "
-                          + name)
-                  .setCumulative()
-                  .setUnit("errors"));
-    }
-
-    void incrementPutFailures() {
-      storePutFailures.increment();
-    }
-
-    <K, V> void registerCallBackMetrics(ChronicleMapStore<K, V> store) {
-      String PERCENTAGE_FREE_SPACE_METRIC =
-          "cache/chroniclemap/percentage_free_space_" + sanitizedName;
-      String REMAINING_AUTORESIZES_METRIC =
-          "cache/chroniclemap/remaining_autoresizes_" + sanitizedName;
-      String MAX_AUTORESIZES_METRIC = "cache/chroniclemap/max_autoresizes_" + sanitizedName;
-
-      metricMaker.newCallbackMetric(
-          PERCENTAGE_FREE_SPACE_METRIC,
-          Long.class,
-          new Description(
-              String.format("The amount of free space in the %s cache as a percentage", name)),
-          () -> (long) store.percentageFreeSpace());
-
-      metricMaker.newCallbackMetric(
-          REMAINING_AUTORESIZES_METRIC,
-          Integer.class,
-          new Description(
-              String.format(
-                  "The number of times the %s cache can automatically expand its capacity", name)),
-          store::remainingAutoResizes);
-
-      metricMaker.newConstantMetric(
-          MAX_AUTORESIZES_METRIC,
-          store.maxAutoResizes(),
-          new Description(
-              String.format(
-                  "The maximum number of times the %s cache can automatically expand its capacity",
-                  name)));
-    }
-  }
 }
diff --git a/src/main/java/com/googlesource/gerrit/modules/cache/chroniclemap/ChronicleMapStoreMetrics.java b/src/main/java/com/googlesource/gerrit/modules/cache/chroniclemap/ChronicleMapStoreMetrics.java
new file mode 100644
index 0000000..cf758b5
--- /dev/null
+++ b/src/main/java/com/googlesource/gerrit/modules/cache/chroniclemap/ChronicleMapStoreMetrics.java
@@ -0,0 +1,76 @@
+// Copyright (C) 2022 The Android Open Source Project
+//
+// Licensed 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 com.googlesource.gerrit.modules.cache.chroniclemap;
+
+import com.google.gerrit.metrics.Counter0;
+import com.google.gerrit.metrics.Description;
+import com.google.gerrit.metrics.MetricMaker;
+
+class ChronicleMapStoreMetrics {
+  private final String sanitizedName;
+  private final MetricMaker metricMaker;
+  private final String name;
+  private final Counter0 storePutFailures;
+
+  ChronicleMapStoreMetrics(String name, MetricMaker metricMaker) {
+    this.name = name;
+    this.sanitizedName = metricMaker.sanitizeMetricName(name);
+    this.metricMaker = metricMaker;
+
+    this.storePutFailures =
+        metricMaker.newCounter(
+            "cache/chroniclemap/store_put_failures_" + sanitizedName,
+            new Description(
+                    "The number of errors caught when inserting entries in chronicle-map store: "
+                        + name)
+                .setCumulative()
+                .setUnit("errors"));
+  }
+
+  void incrementPutFailures() {
+    storePutFailures.increment();
+  }
+
+  <K, V> void registerCallBackMetrics(ChronicleMapStore<K, V> store) {
+    String PERCENTAGE_FREE_SPACE_METRIC =
+        "cache/chroniclemap/percentage_free_space_" + sanitizedName;
+    String REMAINING_AUTORESIZES_METRIC =
+        "cache/chroniclemap/remaining_autoresizes_" + sanitizedName;
+    String MAX_AUTORESIZES_METRIC = "cache/chroniclemap/max_autoresizes_" + sanitizedName;
+
+    metricMaker.newCallbackMetric(
+        PERCENTAGE_FREE_SPACE_METRIC,
+        Long.class,
+        new Description(
+            String.format("The amount of free space in the %s cache as a percentage", name)),
+        () -> (long) store.percentageFreeSpace());
+
+    metricMaker.newCallbackMetric(
+        REMAINING_AUTORESIZES_METRIC,
+        Integer.class,
+        new Description(
+            String.format(
+                "The number of times the %s cache can automatically expand its capacity", name)),
+        store::remainingAutoResizes);
+
+    metricMaker.newConstantMetric(
+        MAX_AUTORESIZES_METRIC,
+        store.maxAutoResizes(),
+        new Description(
+            String.format(
+                "The maximum number of times the %s cache can automatically expand its capacity",
+                name)));
+  }
+}