@VisibleForTesting
    static MetricGroup registerMetricGroup(MetricKey metricKey, MetricGroup metricGroup) {
        ArrayList<String> scopeComponents = getNameSpaceArray(metricKey);
        int size = scopeComponents.size();
        List<String> metricGroupNames = scopeComponents.subList(0, size / 2);
        List<String> metricGroupTypes = scopeComponents.subList(size / 2, size);
        for (int i = 0; i < metricGroupNames.size(); ++i) {
            if (metricGroupTypes.get(i).equals("MetricGroupType.generic")) {
                metricGroup = metricGroup.addGroup(metricGroupNames.get(i));
            } else if (metricGroupTypes.get(i).equals("MetricGroupType.key")) {
                metricGroup =
                        metricGroup.addGroup(metricGroupNames.get(i), metricGroupNames.get(++i));
            }
        }
        return metricGroup;
    }
@Test
    void testRegisterMetricGroup() {
        MetricKey key = MetricKey.create("step", MetricName.named(DEFAULT_NAMESPACE, "name"));

        MetricRegistry registry = NoOpMetricRegistry.INSTANCE;
        GenericMetricGroup root =
                new GenericMetricGroup(
                        registry, new MetricGroupTest.DummyAbstractMetricGroup(registry), "root");
        MetricGroup metricGroup = FlinkMetricContainer.registerMetricGroup(key, root);

        assertThat(metricGroup.getScopeComponents())
                .isEqualTo(Arrays.asList("root", "key", "value").toArray());
    }