You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by ki...@apache.org on 2020/07/03 04:31:02 UTC

[shardingsphere] branch master updated: Metrics facade spi design in Sharding-Proxy (#6245)

This is an automated email from the ASF dual-hosted git repository.

kimmking pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 3940654  Metrics facade spi design in Sharding-Proxy (#6245)
3940654 is described below

commit 3940654e7ecc7b8788410e94394ea3fccfe4c9eb
Author: xiaoyu <54...@qq.com>
AuthorDate: Fri Jul 3 12:30:44 2020 +0800

    Metrics facade spi design in Sharding-Proxy (#6245)
    
    * sharding-proxy sharding-jdbc-spring-boot use common data source configuration。
    
    * Metrics facade spi design in control panel
    
    * fix import.
---
 shardingsphere-control-panel/pom.xml               |   1 +
 .../pom.xml                                        |   4 +-
 .../control/panel/spi/ControlPanelFacade.java}     |  34 ++--
 .../control/panel/spi/FacadeConfiguration.java}    |  30 +---
 .../panel/spi/engine/ControlPanelFacadeEngine.java |  57 +++++++
 .../spi/engine/MetricsHandlerFacadeEngine.java     |  58 +++++++
 .../panel/spi/metrics/MetricsHandlerFacade.java    |  69 ++++++++
 .../shardingsphere-metrics-configuration/pom.xml   |   6 +
 .../configuration/config/MetricsConfiguration.java |   3 +-
 .../metrics/facade/MetricsInitFacade.java          | 129 ++++++++++++++
 .../metrics/facade/MetricsTrackerFacade.java       | 187 ++++-----------------
 ...dingsphere.control.panel.spi.ControlPanelFacade |  18 ++
 ....control.panel.spi.metrics.MetricsHandlerFacade |  18 ++
 .../metrics/facade/MetricsInitFacadeTest.java      |  76 +++++++++
 .../metrics/facade/MetricsTrackerFacadeTest.java   |  87 +++-------
 .../core/schema/OrchestrationSchemaContexts.java   |   6 +-
 .../jdbc/execute/JDBCExecuteEngine.java            |   6 +-
 .../proxy/backend/metrics/MetricsUtils.java        |  10 +-
 .../org/apache/shardingsphere/proxy/Bootstrap.java |  21 ++-
 .../shardingsphere-proxy-common/pom.xml            |   2 +-
 .../frontend/command/CommandExecutorTask.java      |  15 +-
 .../netty/FrontendChannelInboundHandler.java       |   8 +-
 22 files changed, 540 insertions(+), 305 deletions(-)

diff --git a/shardingsphere-control-panel/pom.xml b/shardingsphere-control-panel/pom.xml
index 0d4e6d6..2f34c4e 100644
--- a/shardingsphere-control-panel/pom.xml
+++ b/shardingsphere-control-panel/pom.xml
@@ -35,5 +35,6 @@
         <module>shardingsphere-orchestration</module>
         <module>shardingsphere-opentracing</module>
         <module>shardingsphere-metrics</module>
+        <module>shardingsphere-control-panel-spi</module>
     </modules>
 </project>
diff --git a/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-configuration/pom.xml b/shardingsphere-control-panel/shardingsphere-control-panel-spi/pom.xml
similarity index 92%
copy from shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-configuration/pom.xml
copy to shardingsphere-control-panel/shardingsphere-control-panel-spi/pom.xml
index 7075530..b876761 100644
--- a/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-configuration/pom.xml
+++ b/shardingsphere-control-panel/shardingsphere-control-panel-spi/pom.xml
@@ -20,13 +20,13 @@
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <parent>
-        <artifactId>shardingsphere-metrics</artifactId>
+        <artifactId>shardingsphere-control-panel</artifactId>
         <groupId>org.apache.shardingsphere</groupId>
         <version>5.0.0-RC1-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
-    <artifactId>shardingsphere-metrics-configuration</artifactId>
+    <artifactId>shardingsphere-control-panel-spi</artifactId>
 
     <dependencies>
         <dependency>
diff --git a/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-configuration/src/main/java/org/apache/shardingsphere/metrics/configuration/config/MetricsConfiguration.java b/shardingsphere-control-panel/shardingsphere-control-panel-spi/src/main/java/org/apache/shardingsphere/control/panel/spi/ControlPanelFacade.java
similarity index 62%
copy from shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-configuration/src/main/java/org/apache/shardingsphere/metrics/configuration/config/MetricsConfiguration.java
copy to shardingsphere-control-panel/shardingsphere-control-panel-spi/src/main/java/org/apache/shardingsphere/control/panel/spi/ControlPanelFacade.java
index bcdf8da..94df872 100644
--- a/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-configuration/src/main/java/org/apache/shardingsphere/metrics/configuration/config/MetricsConfiguration.java
+++ b/shardingsphere-control-panel/shardingsphere-control-panel-spi/src/main/java/org/apache/shardingsphere/control/panel/spi/ControlPanelFacade.java
@@ -15,34 +15,20 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.metrics.configuration.config;
+package org.apache.shardingsphere.control.panel.spi;
 
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-import lombok.Setter;
-
-import java.util.Properties;
+import org.apache.shardingsphere.infra.spi.order.OrderedSPI;
 
 /**
- * Metrics configuration.
+ * Interface Control panel facade.
  */
-@Getter
-@Setter
-@AllArgsConstructor
-public final class MetricsConfiguration {
-    
-    private String metricsName;
-    
-    private String host;
-    
-    private Integer port;
+public interface ControlPanelFacade<T extends FacadeConfiguration> extends OrderedSPI<T> {
     
-    private Boolean async;
+    /**
+     * Init.
+     *
+     * @param configuration configuration
+     */
+    void init(T configuration);
     
-    private Boolean enable;
-    
-    private Integer threadCount;
-    
-    private Properties props;
 }
-
diff --git a/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-configuration/src/main/java/org/apache/shardingsphere/metrics/configuration/config/MetricsConfiguration.java b/shardingsphere-control-panel/shardingsphere-control-panel-spi/src/main/java/org/apache/shardingsphere/control/panel/spi/FacadeConfiguration.java
similarity index 61%
copy from shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-configuration/src/main/java/org/apache/shardingsphere/metrics/configuration/config/MetricsConfiguration.java
copy to shardingsphere-control-panel/shardingsphere-control-panel-spi/src/main/java/org/apache/shardingsphere/control/panel/spi/FacadeConfiguration.java
index bcdf8da..85ff833 100644
--- a/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-configuration/src/main/java/org/apache/shardingsphere/metrics/configuration/config/MetricsConfiguration.java
+++ b/shardingsphere-control-panel/shardingsphere-control-panel-spi/src/main/java/org/apache/shardingsphere/control/panel/spi/FacadeConfiguration.java
@@ -15,34 +15,10 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.metrics.configuration.config;
-
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-import lombok.Setter;
-
-import java.util.Properties;
+package org.apache.shardingsphere.control.panel.spi;
 
 /**
- * Metrics configuration.
+ * Interface Facade configuration.
  */
-@Getter
-@Setter
-@AllArgsConstructor
-public final class MetricsConfiguration {
-    
-    private String metricsName;
-    
-    private String host;
-    
-    private Integer port;
-    
-    private Boolean async;
-    
-    private Boolean enable;
-    
-    private Integer threadCount;
-    
-    private Properties props;
+public interface FacadeConfiguration {
 }
-
diff --git a/shardingsphere-control-panel/shardingsphere-control-panel-spi/src/main/java/org/apache/shardingsphere/control/panel/spi/engine/ControlPanelFacadeEngine.java b/shardingsphere-control-panel/shardingsphere-control-panel-spi/src/main/java/org/apache/shardingsphere/control/panel/spi/engine/ControlPanelFacadeEngine.java
new file mode 100644
index 0000000..acca490
--- /dev/null
+++ b/shardingsphere-control-panel/shardingsphere-control-panel-spi/src/main/java/org/apache/shardingsphere/control/panel/spi/engine/ControlPanelFacadeEngine.java
@@ -0,0 +1,57 @@
+/*
+ * 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.shardingsphere.control.panel.spi.engine;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.stream.Collectors;
+import org.apache.shardingsphere.control.panel.spi.ControlPanelFacade;
+import org.apache.shardingsphere.control.panel.spi.FacadeConfiguration;
+import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
+import org.apache.shardingsphere.infra.spi.order.OrderedSPIRegistry;
+
+/**
+ * Control panel facade engine.
+ */
+@SuppressWarnings("ALL")
+public final class ControlPanelFacadeEngine {
+    
+    static {
+        ShardingSphereServiceLoader.register(ControlPanelFacade.class);
+    }
+    
+    /**
+     * Init control panel facade.
+     *
+     * @param facadeConfigurations facade configurations
+     */
+    public void init(final Collection<FacadeConfiguration> facadeConfigurations) {
+        Collection<Class<?>> facadeClassTypes = facadeConfigurations.stream().map(FacadeConfiguration::getClass).collect(Collectors.toList());
+        for (Map.Entry<Class<?>, ControlPanelFacade> entry : OrderedSPIRegistry.getRegisteredServicesByClass(facadeClassTypes, ControlPanelFacade.class).entrySet()) {
+            doInit(facadeConfigurations, entry.getKey(), entry.getValue());
+        }
+    }
+    
+    private void doInit(final Collection<FacadeConfiguration> facadeConfigurations, final Class<?> configurationType, final ControlPanelFacade facade) {
+        for (FacadeConfiguration each : facadeConfigurations) {
+            if (each.getClass().equals(configurationType)) {
+                facade.init(each);
+            }
+        }
+    }
+}
diff --git a/shardingsphere-control-panel/shardingsphere-control-panel-spi/src/main/java/org/apache/shardingsphere/control/panel/spi/engine/MetricsHandlerFacadeEngine.java b/shardingsphere-control-panel/shardingsphere-control-panel-spi/src/main/java/org/apache/shardingsphere/control/panel/spi/engine/MetricsHandlerFacadeEngine.java
new file mode 100644
index 0000000..7ab1571
--- /dev/null
+++ b/shardingsphere-control-panel/shardingsphere-control-panel-spi/src/main/java/org/apache/shardingsphere/control/panel/spi/engine/MetricsHandlerFacadeEngine.java
@@ -0,0 +1,58 @@
+/*
+ * 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.shardingsphere.control.panel.spi.engine;
+
+import java.util.Iterator;
+import java.util.Optional;
+import java.util.ServiceLoader;
+import org.apache.shardingsphere.control.panel.spi.metrics.MetricsHandlerFacade;
+
+/**
+ * Metrics handler facade engine.
+ */
+public final class MetricsHandlerFacadeEngine {
+    
+    private static MetricsHandlerFacade handlerFacade;
+    
+    static {
+        handlerFacade = loadFirst();
+    }
+    
+    /**
+     * Build Metrics handler facade.
+     *
+     * @return Metrics handler facade.
+     */
+    public static Optional<MetricsHandlerFacade> build() {
+        return Optional.ofNullable(handlerFacade);
+    }
+    
+    private static MetricsHandlerFacade loadFirst() {
+        final ServiceLoader<MetricsHandlerFacade> loader = loadAll();
+        final Iterator<MetricsHandlerFacade> iterator = loader.iterator();
+        if (!iterator.hasNext()) {
+            return null;
+        }
+        return iterator.next();
+    }
+    
+    private static ServiceLoader<MetricsHandlerFacade> loadAll() {
+        return ServiceLoader.load(MetricsHandlerFacade.class);
+    }
+}
+
diff --git a/shardingsphere-control-panel/shardingsphere-control-panel-spi/src/main/java/org/apache/shardingsphere/control/panel/spi/metrics/MetricsHandlerFacade.java b/shardingsphere-control-panel/shardingsphere-control-panel-spi/src/main/java/org/apache/shardingsphere/control/panel/spi/metrics/MetricsHandlerFacade.java
new file mode 100644
index 0000000..693a614
--- /dev/null
+++ b/shardingsphere-control-panel/shardingsphere-control-panel-spi/src/main/java/org/apache/shardingsphere/control/panel/spi/metrics/MetricsHandlerFacade.java
@@ -0,0 +1,69 @@
+/*
+ * 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.shardingsphere.control.panel.spi.metrics;
+
+import java.util.function.Supplier;
+
+/**
+ * Metrics Handler facade.
+ */
+public interface MetricsHandlerFacade {
+    
+    /**
+     * Increment of counter metrics tracker.
+     *
+     * @param metricsLabel metrics label
+     * @param labelValues  label values
+     */
+    void counterInc(String metricsLabel, String... labelValues);
+    
+    /**
+     * Increment of gauge metrics tracker.
+     *
+     * @param metricsLabel metrics label
+     * @param labelValues  label values
+     */
+    void gaugeInc(String metricsLabel, String... labelValues);
+    
+    /**
+     * Decrement of gauge metrics tracker.
+     *
+     * @param metricsLabel metrics label
+     * @param labelValues  label values
+     */
+    void gaugeDec(String metricsLabel, String... labelValues);
+    
+    /**
+     * Start timer of histogram metrics tracker.
+     *
+     * @param metricsLabel metrics label
+     * @param labelValues  label values
+     * @return histogram metrics tracker delegate
+     */
+    Supplier<Boolean> histogramStartTimer(String metricsLabel, String... labelValues);
+    
+    /**
+     * Start timer of summary metrics tracker.
+     *
+     * @param metricsLabel metrics label
+     * @param labelValues  label values
+     * @return summary metrics tracker delegate
+     */
+    Supplier<Boolean> summaryStartTimer(String metricsLabel, String... labelValues);
+}
+
diff --git a/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-configuration/pom.xml b/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-configuration/pom.xml
index 7075530..6f5b5e3 100644
--- a/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-configuration/pom.xml
+++ b/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-configuration/pom.xml
@@ -34,5 +34,11 @@
             <artifactId>shardingsphere-infra-common</artifactId>
             <version>${project.version}</version>
         </dependency>
+
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-control-panel-spi</artifactId>
+            <version>${project.version}</version>
+        </dependency>
     </dependencies>
 </project>
diff --git a/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-configuration/src/main/java/org/apache/shardingsphere/metrics/configuration/config/MetricsConfiguration.java b/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-configuration/src/main/java/org/apache/shardingsphere/metrics/configuration/config/MetricsConfiguration.java
index bcdf8da..ffada64 100644
--- a/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-configuration/src/main/java/org/apache/shardingsphere/metrics/configuration/config/MetricsConfiguration.java
+++ b/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-configuration/src/main/java/org/apache/shardingsphere/metrics/configuration/config/MetricsConfiguration.java
@@ -22,6 +22,7 @@ import lombok.Getter;
 import lombok.Setter;
 
 import java.util.Properties;
+import org.apache.shardingsphere.control.panel.spi.FacadeConfiguration;
 
 /**
  * Metrics configuration.
@@ -29,7 +30,7 @@ import java.util.Properties;
 @Getter
 @Setter
 @AllArgsConstructor
-public final class MetricsConfiguration {
+public final class MetricsConfiguration implements FacadeConfiguration {
     
     private String metricsName;
     
diff --git a/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-facade/src/main/java/org/apache/shardingsphere/metrics/facade/MetricsInitFacade.java b/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-facade/src/main/java/org/apache/shardingsphere/metrics/facade/MetricsInitFacade.java
new file mode 100644
index 0000000..eef97e6
--- /dev/null
+++ b/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-facade/src/main/java/org/apache/shardingsphere/metrics/facade/MetricsInitFacade.java
@@ -0,0 +1,129 @@
+/*
+ * 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.shardingsphere.metrics.facade;
+
+import com.google.common.base.Preconditions;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.ServiceLoader;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shardingsphere.control.panel.spi.ControlPanelFacade;
+import org.apache.shardingsphere.metrics.configuration.config.MetricsConfiguration;
+import org.apache.shardingsphere.metrics.facade.handler.MetricsTrackerHandler;
+import org.apache.shardingsphere.metrics.spi.MetricsTrackerManager;
+
+/**
+ * Metrics tracker facade.
+ */
+@Slf4j
+public final class MetricsInitFacade implements ControlPanelFacade<MetricsConfiguration> {
+    
+    private static MetricsTrackerManager metricsTrackerManager;
+    
+    private static volatile boolean enabled;
+    
+    /**
+     * Get enabled boolean.
+     *
+     * @return boolean enabled
+     */
+    public static boolean getEnabled() {
+        return enabled;
+    }
+    
+    /**
+     * Get metrics tracker manager.
+     *
+     * @return metrics tracker manager
+     */
+    public static MetricsTrackerManager getMetricsTrackerManager() {
+        return metricsTrackerManager;
+    }
+    
+    /**
+     * Init for metrics tracker manager.
+     *
+     * @param metricsConfiguration metrics configuration
+     */
+    @Override
+    public void init(final MetricsConfiguration metricsConfiguration) {
+        if (enabled) {
+            return;
+        }
+        doInit(metricsConfiguration);
+    }
+    
+    private static void doInit(final MetricsConfiguration metricsConfiguration) {
+        Preconditions.checkNotNull(metricsConfiguration, "metrics configuration can not be null.");
+        metricsTrackerManager = loadMetricsManager().get(metricsConfiguration.getMetricsName());
+        Preconditions.checkNotNull(metricsTrackerManager, "Can not find metrics tracker manager with metrics name in metrics configuration.");
+        metricsTrackerManager.start(metricsConfiguration);
+        MetricsTrackerHandler.getInstance().init(metricsConfiguration.getAsync(), metricsConfiguration.getThreadCount(), metricsTrackerManager);
+        enabled = true;
+    }
+    
+    /**
+     * Stop to metrics.
+     */
+    public static void close() {
+        if (!enabled) {
+            return;
+        }
+        if (null != metricsTrackerManager) {
+            metricsTrackerManager.stop();
+        }
+        MetricsTrackerHandler.getInstance().close();
+        enabled = false;
+    }
+    
+    
+    /**
+     * Restart.
+     *
+     * @param metricsConfiguration metrics configuration
+     */
+    public static void restart(final MetricsConfiguration metricsConfiguration) {
+        close();
+        doInit(metricsConfiguration);
+    }
+    
+    private static Map<String, MetricsTrackerManager> loadMetricsManager() {
+        Map<String, MetricsTrackerManager> metricsMap = new HashMap<>();
+        for (MetricsTrackerManager each : ServiceLoader.load(MetricsTrackerManager.class)) {
+            if (metricsMap.containsKey(each.getType())) {
+                log.warn("Find more than one {} metricsTracker manager implementation class, use `{}` now",
+                        each.getType(), metricsMap.get(each.getType()).getClass().getName());
+                continue;
+            }
+            metricsMap.put(each.getType(), each);
+        }
+        return metricsMap;
+    }
+    
+    @Override
+    public int getOrder() {
+        return 0;
+    }
+    
+    @Override
+    public Class<MetricsConfiguration> getTypeClass() {
+        return MetricsConfiguration.class;
+    }
+    
+}
+
diff --git a/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-facade/src/main/java/org/apache/shardingsphere/metrics/facade/MetricsTrackerFacade.java b/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-facade/src/main/java/org/apache/shardingsphere/metrics/facade/MetricsTrackerFacade.java
index d3f4008..f35daf3 100644
--- a/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-facade/src/main/java/org/apache/shardingsphere/metrics/facade/MetricsTrackerFacade.java
+++ b/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-facade/src/main/java/org/apache/shardingsphere/metrics/facade/MetricsTrackerFacade.java
@@ -17,200 +17,75 @@
 
 package org.apache.shardingsphere.metrics.facade;
 
-import com.google.common.base.Preconditions;
-import java.util.HashMap;
-import java.util.Map;
 import java.util.Optional;
-import java.util.ServiceLoader;
-import lombok.Getter;
+import java.util.function.Supplier;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.shardingsphere.control.panel.spi.metrics.MetricsHandlerFacade;
 import org.apache.shardingsphere.metrics.api.HistogramMetricsTrackerDelegate;
 import org.apache.shardingsphere.metrics.api.SummaryMetricsTrackerDelegate;
-import org.apache.shardingsphere.metrics.configuration.config.MetricsConfiguration;
 import org.apache.shardingsphere.metrics.facade.handler.MetricsTrackerHandler;
-import org.apache.shardingsphere.metrics.spi.MetricsTrackerManager;
 
 /**
  * Metrics tracker facade.
  */
 @Slf4j
-public final class MetricsTrackerFacade {
+public final class MetricsTrackerFacade implements MetricsHandlerFacade {
     
-    private static final Map<String, MetricsTrackerManager> METRICS_MAP = new HashMap<>();
-    
-    @Getter
-    private MetricsTrackerManager metricsTrackerManager;
-    
-    @Getter
-    private volatile boolean enabled;
-    
-    private MetricsTrackerFacade() {
-        loadMetricsManager();
-    }
-    
-    /**
-     * Get metrics tracker facade of lazy load singleton.
-     *
-     * @return metrics tracker facade
-     */
-    public static MetricsTrackerFacade getInstance() {
-        return MetricsTrackerFacadeHolder.INSTANCE;
-    }
-    
-    /**
-     * Find metrics tracker manager.
-     *
-     * @param metricsName metrics name
-     * @return metrics tracker manager
-     */
-    public MetricsTrackerManager findMetricsTrackerManager(final String metricsName) {
-        return METRICS_MAP.get(metricsName);
-    }
-    
-    /**
-     * Init for metrics tracker manager.
-     *
-     * @param metricsConfiguration metrics configuration
-     */
-    public void init(final MetricsConfiguration metricsConfiguration) {
-        if (enabled) {
-            return;
-        }
-        Preconditions.checkNotNull(metricsConfiguration, "metrics configuration can not be null.");
-        metricsTrackerManager = findMetricsTrackerManager(metricsConfiguration.getMetricsName());
-        Preconditions.checkNotNull(metricsTrackerManager, "Can not find metrics tracker manager with metrics name in metrics configuration.");
-        metricsTrackerManager.start(metricsConfiguration);
-        MetricsTrackerHandler.getInstance().init(metricsConfiguration.getAsync(), metricsConfiguration.getThreadCount(), metricsTrackerManager);
-        enabled = true;
-    }
-    
-    /**
-     * Increment of counter metrics tracker.
-     *
-     * @param metricsLabel metrics label
-     * @param labelValues  label values
-     */
+    @Override
     public void counterInc(final String metricsLabel, final String... labelValues) {
-        if (enabled) {
+        if (MetricsInitFacade.getEnabled()) {
             MetricsTrackerHandler.getInstance().counterInc(metricsLabel, labelValues);
         }
     }
     
-    /**
-     * Increment of gauge metrics tracker.
-     *
-     * @param metricsLabel metrics label
-     * @param labelValues  label values
-     */
+    @Override
     public void gaugeInc(final String metricsLabel, final String... labelValues) {
-        if (enabled) {
+        if (MetricsInitFacade.getEnabled()) {
             MetricsTrackerHandler.getInstance().gaugeInc(metricsLabel, labelValues);
         }
     }
     
-    /**
-     * Decrement of gauge metrics tracker.
-     *
-     * @param metricsLabel metrics label
-     * @param labelValues  label values
-     */
+    @Override
     public void gaugeDec(final String metricsLabel, final String... labelValues) {
-        if (enabled) {
+        if (MetricsInitFacade.getEnabled()) {
             MetricsTrackerHandler.getInstance().gaugeDec(metricsLabel, labelValues);
         }
     }
     
-    /**
-     * Start timer of histogram metrics tracker.
-     *
-     * @param metricsLabel metrics label
-     * @param labelValues  label values
-     * @return histogram metrics tracker delegate
-     */
-    public Optional<HistogramMetricsTrackerDelegate> histogramStartTimer(final String metricsLabel, final String... labelValues) {
-        if (!enabled) {
-            return Optional.empty();
+    @Override
+    public Supplier<Boolean> histogramStartTimer(final String metricsLabel, final String... labelValues) {
+        if (!MetricsInitFacade.getEnabled()) {
+            return () -> false;
         }
-        return MetricsTrackerHandler.getInstance().histogramStartTimer(metricsLabel, labelValues);
+        Optional<HistogramMetricsTrackerDelegate> histogramMetricsTrackerDelegate = MetricsTrackerHandler.getInstance().histogramStartTimer(metricsLabel, labelValues);
+        return () -> {
+            histogramMetricsTrackerDelegate.ifPresent(this::histogramObserveDuration);
+            return true;
+        };
     }
     
-    /**
-     * Observe amount of time since start time with histogram metrics tracker.
-     *
-     * @param delegate histogram metrics tracker delegate
-     */
-    public void histogramObserveDuration(final HistogramMetricsTrackerDelegate delegate) {
-        if (enabled) {
+    private void histogramObserveDuration(final HistogramMetricsTrackerDelegate delegate) {
+        if (MetricsInitFacade.getEnabled()) {
             MetricsTrackerHandler.getInstance().histogramObserveDuration(delegate);
         }
     }
     
-    /**
-     * Start timer of summary metrics tracker.
-     *
-     * @param metricsLabel metrics label
-     * @param labelValues  label values
-     * @return summary metrics tracker delegate
-     */
-    public Optional<SummaryMetricsTrackerDelegate> summaryStartTimer(final String metricsLabel, final String... labelValues) {
-        if (!enabled) {
-            return Optional.empty();
+    @Override
+    public Supplier<Boolean> summaryStartTimer(final String metricsLabel, final String... labelValues) {
+        if (!MetricsInitFacade.getEnabled()) {
+            return () -> false;
         }
-        return MetricsTrackerHandler.getInstance().summaryStartTimer(metricsLabel, labelValues);
+        Optional<SummaryMetricsTrackerDelegate> optionalSummaryMetricsTrackerDelegate = MetricsTrackerHandler.getInstance().summaryStartTimer(metricsLabel, labelValues);
+        return () -> {
+            optionalSummaryMetricsTrackerDelegate.ifPresent(this::summaryObserveDuration);
+            return true;
+        };
     }
     
-    /**
-     * Observe amount of time since start time with summary metrics tracker.
-     *
-     * @param delegate summary metrics tracker delegate
-     */
-    public void summaryObserveDuration(final SummaryMetricsTrackerDelegate delegate) {
-        if (enabled) {
+    private void summaryObserveDuration(final SummaryMetricsTrackerDelegate delegate) {
+        if (MetricsInitFacade.getEnabled()) {
             MetricsTrackerHandler.getInstance().summaryObserveDuration(delegate);
         }
     }
-    
-    /**
-     * Stop to metrics.
-     */
-    public void stop() {
-        if (!enabled) {
-            return;
-        }
-        if (null != metricsTrackerManager) {
-            metricsTrackerManager.stop();
-        }
-        MetricsTrackerHandler.getInstance().close();
-        enabled = false;
-    }
-    
-    /**
-     * Restart to metrics.
-     *
-     * @param metricsConfiguration metrics configuration
-     */
-    public void restart(final MetricsConfiguration metricsConfiguration) {
-        stop();
-        init(metricsConfiguration);
-    }
-    
-    private void loadMetricsManager() {
-        for (MetricsTrackerManager each : ServiceLoader.load(MetricsTrackerManager.class)) {
-            if (METRICS_MAP.containsKey(each.getType())) {
-                log.warn("Find more than one {} metricsTracker manager implementation class, use `{}` now",
-                        each.getType(), METRICS_MAP.get(each.getType()).getClass().getName());
-                continue;
-            }
-            METRICS_MAP.put(each.getType(), each);
-        }
-    }
-    
-    /**
-     * Metrics tracker facade holder.
-     */
-    private static class MetricsTrackerFacadeHolder {
-        
-        private static final MetricsTrackerFacade INSTANCE = new MetricsTrackerFacade();
-    }
 }
 
diff --git a/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-facade/src/main/resources/META-INF/services/org.apache.shardingsphere.control.panel.spi.ControlPanelFacade b/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-facade/src/main/resources/META-INF/services/org.apache.shardingsphere.control.panel.spi.ControlPanelFacade
new file mode 100644
index 0000000..2799a2a
--- /dev/null
+++ b/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-facade/src/main/resources/META-INF/services/org.apache.shardingsphere.control.panel.spi.ControlPanelFacade
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+org.apache.shardingsphere.metrics.facade.MetricsInitFacade
diff --git a/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-facade/src/main/resources/META-INF/services/org.apache.shardingsphere.control.panel.spi.metrics.MetricsHandlerFacade b/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-facade/src/main/resources/META-INF/services/org.apache.shardingsphere.control.panel.spi.metrics.MetricsHandlerFacade
new file mode 100644
index 0000000..fd719ab
--- /dev/null
+++ b/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-facade/src/main/resources/META-INF/services/org.apache.shardingsphere.control.panel.spi.metrics.MetricsHandlerFacade
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+org.apache.shardingsphere.metrics.facade.MetricsTrackerFacade
diff --git a/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-facade/src/test/java/org/apache/shardingsphere/metrics/facade/MetricsInitFacadeTest.java b/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-facade/src/test/java/org/apache/shardingsphere/metrics/facade/MetricsInitFacadeTest.java
new file mode 100644
index 0000000..1e8d475
--- /dev/null
+++ b/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-facade/src/test/java/org/apache/shardingsphere/metrics/facade/MetricsInitFacadeTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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.shardingsphere.metrics.facade;
+
+import java.util.LinkedList;
+import java.util.List;
+import org.apache.shardingsphere.control.panel.spi.FacadeConfiguration;
+import org.apache.shardingsphere.control.panel.spi.engine.ControlPanelFacadeEngine;
+import org.apache.shardingsphere.metrics.configuration.config.MetricsConfiguration;
+import org.apache.shardingsphere.metrics.facade.fixture.SecondMetricsTrackerManagerFixture;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+
+@RunWith(MockitoJUnitRunner.class)
+public final class MetricsInitFacadeTest {
+    
+    @Before
+    public void setUp() {
+        MetricsConfiguration metricsConfiguration = new MetricsConfiguration("fixture", null, null, false, true, 8, null);
+        List<FacadeConfiguration> facadeConfigurations = new LinkedList<>();
+        facadeConfigurations.add(metricsConfiguration);
+        new ControlPanelFacadeEngine().init(facadeConfigurations);
+    }
+    
+    @Test
+    public void assertInit() {
+        assertThat(MetricsInitFacade.getEnabled(), is(true));
+    }
+    
+    @Test
+    public void assertFindMetricsTrackerManager() {
+        assertNotNull(MetricsInitFacade.getMetricsTrackerManager());
+        assertThat(MetricsInitFacade.getMetricsTrackerManager().getClass().getName(), is(SecondMetricsTrackerManagerFixture.class.getName()));
+    }
+    
+    @Test
+    public void testClose() {
+        MetricsInitFacade.close();
+        assertThat(MetricsInitFacade.getEnabled(), is(false));
+    }
+    
+    @Test
+    public void restart() {
+        MetricsConfiguration metricsConfiguration = new MetricsConfiguration("fixture", null, null, false, true, 8, null);
+        MetricsInitFacade.restart(metricsConfiguration);
+        assertThat(MetricsInitFacade.getEnabled(), is(true));
+    }
+    
+    @After
+    public void clean() {
+        MetricsInitFacade.close();
+    }
+}
+
diff --git a/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-facade/src/test/java/org/apache/shardingsphere/metrics/facade/MetricsTrackerFacadeTest.java b/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-facade/src/test/java/org/apache/shardingsphere/metrics/facade/MetricsTrackerFacadeTest.java
index 5480729..e509b70 100644
--- a/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-facade/src/test/java/org/apache/shardingsphere/metrics/facade/MetricsTrackerFacadeTest.java
+++ b/shardingsphere-control-panel/shardingsphere-metrics/shardingsphere-metrics-facade/src/test/java/org/apache/shardingsphere/metrics/facade/MetricsTrackerFacadeTest.java
@@ -17,47 +17,23 @@
 
 package org.apache.shardingsphere.metrics.facade;
 
-import java.util.Optional;
-import org.apache.shardingsphere.metrics.api.HistogramMetricsTrackerDelegate;
-import org.apache.shardingsphere.metrics.api.NoneHistogramMetricsTrackerDelegate;
-import org.apache.shardingsphere.metrics.api.NoneSummaryMetricsTrackerDelegate;
-import org.apache.shardingsphere.metrics.api.SummaryMetricsTrackerDelegate;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.function.Supplier;
+import org.apache.shardingsphere.control.panel.spi.FacadeConfiguration;
+import org.apache.shardingsphere.control.panel.spi.engine.ControlPanelFacadeEngine;
 import org.apache.shardingsphere.metrics.configuration.config.MetricsConfiguration;
-import org.apache.shardingsphere.metrics.facade.fixture.SecondMetricsTrackerManagerFixture;
-import org.apache.shardingsphere.metrics.facade.util.FieldUtil;
-import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.junit.MockitoJUnitRunner;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertThat;
 
 @RunWith(MockitoJUnitRunner.class)
 public final class MetricsTrackerFacadeTest {
     
-    private final MetricsTrackerFacade metricsTrackerFacade = MetricsTrackerFacade.getInstance();
-    
-    @Before
-    public void setUp() {
-        MetricsConfiguration metricsConfiguration = new MetricsConfiguration("fixture", null, null, false, true, 8, null);
-        metricsTrackerFacade.init(metricsConfiguration);
-    }
-    
-    @Test
-    public void assertInit() {
-        MetricsConfiguration metricsConfiguration = new MetricsConfiguration("fixture", null, null, false, true, 8, null);
-        metricsTrackerFacade.init(metricsConfiguration);
-        assertThat(metricsTrackerFacade.isEnabled(), is(true));
-    }
-    
-    @Test
-    public void assertFindMetricsTrackerManager() {
-        assertNull(metricsTrackerFacade.findMetricsTrackerManager("fixture1"));
-        assertNotNull(metricsTrackerFacade.findMetricsTrackerManager("fixture"));
-    }
+    private final MetricsTrackerFacade metricsTrackerFacade = new MetricsTrackerFacade();
     
     @Test
     public void assertCounterInc() {
@@ -75,46 +51,23 @@ public final class MetricsTrackerFacadeTest {
     }
     
     @Test
-    public void assertHistogram() {
-        assertThat(metricsTrackerFacade.getMetricsTrackerManager().getClass().getName(), is(SecondMetricsTrackerManagerFixture.class.getName()));
-        Optional<HistogramMetricsTrackerDelegate> histogramDelegate = metricsTrackerFacade.histogramStartTimer("request");
-        assertThat(histogramDelegate.isPresent(), is(true));
-        histogramDelegate.ifPresent(delegate -> {
-            metricsTrackerFacade.histogramObserveDuration(delegate);
-            assertThat(delegate.getClass().getName(), is(NoneHistogramMetricsTrackerDelegate.class.getName()));
-        });
-    
-        FieldUtil.setField(metricsTrackerFacade, "enabled", false);
-        Optional<HistogramMetricsTrackerDelegate> empty = metricsTrackerFacade.histogramStartTimer("request");
-        assertThat(empty, is(Optional.empty()));
-    }
-    
-    @Test
-    public void summary() {
-        assertThat(metricsTrackerFacade.getMetricsTrackerManager().getClass().getName(), is(SecondMetricsTrackerManagerFixture.class.getName()));
-        Optional<SummaryMetricsTrackerDelegate> summaryDelegate = metricsTrackerFacade.summaryStartTimer("request");
-        assertThat(summaryDelegate.isPresent(), is(true));
-        summaryDelegate.ifPresent(delegate -> {
-            metricsTrackerFacade.summaryObserveDuration(delegate);
-            assertThat(delegate.getClass().getName(), is(NoneSummaryMetricsTrackerDelegate.class.getName()));
-        });
-    
-        FieldUtil.setField(metricsTrackerFacade, "enabled", false);
-        Optional<SummaryMetricsTrackerDelegate> empty = metricsTrackerFacade.summaryStartTimer("request");
-        assertThat(empty, is(Optional.empty()));
+    public void assertHistogramAndSummary() {
+        Supplier<Boolean> histogramDelegate = metricsTrackerFacade.histogramStartTimer("request");
+        assertThat(histogramDelegate.get(), is(false));
+        Supplier<Boolean> summaryDelegate = metricsTrackerFacade.summaryStartTimer("request");
+        assertThat(summaryDelegate.get(), is(false));
+        init();
+        Supplier<Boolean> emptyHistogram = metricsTrackerFacade.histogramStartTimer("request");
+        assertThat(emptyHistogram.get(), is(true));
+        Supplier<Boolean> empty = metricsTrackerFacade.summaryStartTimer("request");
+        assertThat(empty.get(), is(true));
     }
     
-    @Test
-    public void testStop() {
-        metricsTrackerFacade.stop();
-        assertThat(metricsTrackerFacade.isEnabled(), is(false));
-    }
-    
-    @Test
-    public void restart() {
+    private void init() {
         MetricsConfiguration metricsConfiguration = new MetricsConfiguration("fixture", null, null, false, true, 8, null);
-        metricsTrackerFacade.restart(metricsConfiguration);
-        assertThat(metricsTrackerFacade.isEnabled(), is(true));
+        List<FacadeConfiguration> facadeConfigurations = new LinkedList<>();
+        facadeConfigurations.add(metricsConfiguration);
+        new ControlPanelFacadeEngine().init(facadeConfigurations);
     }
 }
 
diff --git a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-schema/src/main/java/org/apache/shardingsphere/orchestration/core/schema/OrchestrationSchemaContexts.java b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-schema/src/main/java/org/apache/shardingsphere/orchestration/core/schema/OrchestrationSchemaContexts.java
index 0ce70b4..89d0157 100644
--- a/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-schema/src/main/java/org/apache/shardingsphere/orchestration/core/schema/OrchestrationSchemaContexts.java
+++ b/shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-schema/src/main/java/org/apache/shardingsphere/orchestration/core/schema/OrchestrationSchemaContexts.java
@@ -42,7 +42,7 @@ import org.apache.shardingsphere.kernel.context.runtime.RuntimeContext;
 import org.apache.shardingsphere.kernel.context.schema.DataSourceParameter;
 import org.apache.shardingsphere.kernel.context.schema.ShardingSphereSchema;
 import org.apache.shardingsphere.metrics.configuration.config.MetricsConfiguration;
-import org.apache.shardingsphere.metrics.facade.MetricsTrackerFacade;
+import org.apache.shardingsphere.metrics.facade.MetricsInitFacade;
 import org.apache.shardingsphere.orchestration.core.common.event.AuthenticationChangedEvent;
 import org.apache.shardingsphere.orchestration.core.common.event.DataSourceChangedEvent;
 import org.apache.shardingsphere.orchestration.core.common.event.MetricsConfigurationChangedEvent;
@@ -165,9 +165,9 @@ public abstract class OrchestrationSchemaContexts implements SchemaContextsAware
     public synchronized void renew(final MetricsConfigurationChangedEvent event) {
         MetricsConfiguration metricsConfiguration = event.getMetricsConfiguration();
         if (metricsConfiguration.getEnable()) {
-            MetricsTrackerFacade.getInstance().restart(metricsConfiguration);
+            MetricsInitFacade.restart(metricsConfiguration);
         } else {
-            MetricsTrackerFacade.getInstance().stop();
+            MetricsInitFacade.close();
         }
     }
     
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/execute/JDBCExecuteEngine.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/execute/JDBCExecuteEngine.java
index faff2b3..7a6732b 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/execute/JDBCExecuteEngine.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/execute/JDBCExecuteEngine.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.proxy.backend.communication.jdbc.execute;
 
 import com.google.common.base.Strings;
 import lombok.Getter;
+import org.apache.shardingsphere.control.panel.spi.engine.MetricsHandlerFacadeEngine;
 import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
 import org.apache.shardingsphere.infra.executor.kernel.InputGroup;
 import org.apache.shardingsphere.infra.executor.sql.ExecutorConstant;
@@ -35,7 +36,6 @@ import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.executor.Exec
 import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.executor.SQLExecutor;
 import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.group.StatementOption;
 import org.apache.shardingsphere.metrics.enums.MetricsLabelEnum;
-import org.apache.shardingsphere.metrics.facade.MetricsTrackerFacade;
 import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
 import org.apache.shardingsphere.proxy.backend.communication.jdbc.execute.callback.ProxySQLExecutorCallback;
 import org.apache.shardingsphere.proxy.backend.communication.jdbc.wrapper.JDBCExecutorWrapper;
@@ -97,7 +97,7 @@ public final class JDBCExecuteEngine implements SQLExecuteEngine {
         }
         ExecuteResult executeResult = executeResults.iterator().next();
         if (executeResult instanceof ExecuteQueryResult) {
-            MetricsTrackerFacade.getInstance().counterInc(MetricsLabelEnum.SQL_STATEMENT_COUNT.getName(), "SELECT");
+            MetricsHandlerFacadeEngine.build().ifPresent(metricsHandlerFacade -> metricsHandlerFacade.counterInc(MetricsLabelEnum.SQL_STATEMENT_COUNT.getName(), "SELECT"));
             return getExecuteQueryResponse(((ExecuteQueryResult) executeResult).getQueryHeaders(), executeResults);
         } else {
             UpdateResponse updateResponse = new UpdateResponse(executeResults);
@@ -109,7 +109,7 @@ public final class JDBCExecuteEngine implements SQLExecuteEngine {
                 updateResponse.setType("UPDATE");
             }
             if (!Strings.isNullOrEmpty(updateResponse.getType())) {
-                MetricsTrackerFacade.getInstance().counterInc(MetricsLabelEnum.SQL_STATEMENT_COUNT.getName(), updateResponse.getType());
+                MetricsHandlerFacadeEngine.build().ifPresent(metricsHandlerFacade -> metricsHandlerFacade.counterInc(MetricsLabelEnum.SQL_STATEMENT_COUNT.getName(), updateResponse.getType()));
             }
             return updateResponse;
         }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/metrics/MetricsUtils.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/metrics/MetricsUtils.java
index a00b06a..07de852 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/metrics/MetricsUtils.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/metrics/MetricsUtils.java
@@ -17,8 +17,8 @@
 
 package org.apache.shardingsphere.proxy.backend.metrics;
 
+import org.apache.shardingsphere.control.panel.spi.engine.MetricsHandlerFacadeEngine;
 import org.apache.shardingsphere.metrics.enums.MetricsLabelEnum;
-import org.apache.shardingsphere.metrics.facade.MetricsTrackerFacade;
 import org.apache.shardingsphere.shadow.rule.ShadowRule;
 import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import org.apache.shardingsphere.infra.route.context.RouteContext;
@@ -42,9 +42,9 @@ public final class MetricsUtils {
             for (RouteUnit each : routeUnits) {
                 Collection<RouteMapper> tableMappers = each.getTableMappers();
                 RouteMapper dataSourceMapper = each.getDataSourceMapper();
-                MetricsTrackerFacade.getInstance().counterInc(MetricsLabelEnum.SHARDING_DATASOURCE.getName(), dataSourceMapper.getActualName());
+                MetricsHandlerFacadeEngine.build().ifPresent(metricsHandlerFacade -> metricsHandlerFacade.counterInc(MetricsLabelEnum.SHARDING_DATASOURCE.getName(), dataSourceMapper.getActualName()));
                 for (RouteMapper table : tableMappers) {
-                    MetricsTrackerFacade.getInstance().counterInc(MetricsLabelEnum.SHARDING_TABLE.getName(), table.getActualName());
+                    MetricsHandlerFacadeEngine.build().ifPresent(metricsHandlerFacade -> metricsHandlerFacade.counterInc(MetricsLabelEnum.SHARDING_TABLE.getName(), table.getActualName()));
                 }
             }
         }
@@ -56,7 +56,7 @@ public final class MetricsUtils {
      * @param labelValue label value
      */
     public static void buriedTransactionMetric(final String labelValue) {
-        MetricsTrackerFacade.getInstance().counterInc(MetricsLabelEnum.TRANSACTION.getName(), labelValue);
+        MetricsHandlerFacadeEngine.build().ifPresent(metricsHandlerFacade -> metricsHandlerFacade.counterInc(MetricsLabelEnum.TRANSACTION.getName(), labelValue));
     }
     
     /**
@@ -68,7 +68,7 @@ public final class MetricsUtils {
     public static void buriedShardingRuleMetrics(final RouteContext routeContext, final Collection<ShardingSphereRule> rules) {
         routeContext.getRouteResult().getActualDataSourceNames().forEach(dataSourceName -> rules.forEach(each -> {
             if (each instanceof ShadowRule && ((ShadowRule) each).getShadowMappings().containsValue(dataSourceName)) {
-                MetricsTrackerFacade.getInstance().counterInc(MetricsLabelEnum.SHADOW_HIT_TOTAL.getName());
+                MetricsHandlerFacadeEngine.build().ifPresent(metricsHandlerFacade -> metricsHandlerFacade.counterInc(MetricsLabelEnum.SHADOW_HIT_TOTAL.getName()));
             }
         }));
     }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/Bootstrap.java b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/Bootstrap.java
index 67d575d..0895379 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/Bootstrap.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/Bootstrap.java
@@ -19,6 +19,8 @@ package org.apache.shardingsphere.proxy;
 
 import com.google.common.base.Joiner;
 import com.google.common.primitives.Ints;
+import java.util.LinkedList;
+import java.util.List;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import org.apache.commons.collections4.CollectionUtils;
@@ -26,6 +28,8 @@ import org.apache.shardingsphere.cluster.configuration.config.ClusterConfigurati
 import org.apache.shardingsphere.cluster.configuration.swapper.ClusterConfigurationYamlSwapper;
 import org.apache.shardingsphere.cluster.configuration.yaml.YamlClusterConfiguration;
 import org.apache.shardingsphere.cluster.facade.ClusterFacade;
+import org.apache.shardingsphere.control.panel.spi.engine.ControlPanelFacadeEngine;
+import org.apache.shardingsphere.control.panel.spi.FacadeConfiguration;
 import org.apache.shardingsphere.infra.auth.Authentication;
 import org.apache.shardingsphere.infra.auth.yaml.config.YamlAuthenticationConfiguration;
 import org.apache.shardingsphere.infra.auth.yaml.swapper.AuthenticationYamlSwapper;
@@ -45,7 +49,6 @@ import org.apache.shardingsphere.masterslave.rule.MasterSlaveRule;
 import org.apache.shardingsphere.metrics.configuration.config.MetricsConfiguration;
 import org.apache.shardingsphere.metrics.configuration.swapper.MetricsConfigurationYamlSwapper;
 import org.apache.shardingsphere.metrics.configuration.yaml.YamlMetricsConfiguration;
-import org.apache.shardingsphere.metrics.facade.MetricsTrackerFacade;
 import org.apache.shardingsphere.opentracing.ShardingTracer;
 import org.apache.shardingsphere.orchestration.center.yaml.config.YamlOrchestrationConfiguration;
 import org.apache.shardingsphere.orchestration.center.yaml.swapper.OrchestrationConfigurationYamlSwapper;
@@ -154,11 +157,19 @@ public final class Bootstrap {
                                    final ClusterConfiguration cluster, final boolean isOrchestration) throws SQLException {
         initProxySchemaContexts(schemaDataSources, schemaRules, authentication, properties, isOrchestration);
         log(authentication, properties);
-        initMetrics(metricsConfiguration);
+        initControlPanelFacade(metricsConfiguration);
         initOpenTracing();
         initCluster(cluster);
     }
     
+    private static void initControlPanelFacade(final MetricsConfiguration metricsConfiguration) {
+        List<FacadeConfiguration> facadeConfigurations = new LinkedList<>();
+        if (null != metricsConfiguration && metricsConfiguration.getEnable()) {
+            facadeConfigurations.add(metricsConfiguration);
+        }
+        new ControlPanelFacadeEngine().init(facadeConfigurations);
+    }
+    
     private static void initProxySchemaContexts(final Map<String, Map<String, DataSourceParameter>> schemaDataSources, final Map<String, Collection<RuleConfiguration>> schemaRules,
                                                 final Authentication authentication, final Properties properties, final boolean isOrchestration) throws SQLException {
         DatabaseType databaseType = DatabaseTypes.getActualDatabaseType(
@@ -244,12 +255,6 @@ public final class Bootstrap {
         }
     }
     
-    private static void initMetrics(final MetricsConfiguration metricsConfiguration) {
-        if (null != metricsConfiguration && metricsConfiguration.getEnable()) {
-            MetricsTrackerFacade.getInstance().init(metricsConfiguration);
-        }
-    }
-    
     private static void initCluster(final ClusterConfiguration clusterConfiguration) {
         if (null != ClusterFacade.getInstance()
                 && ProxySchemaContexts.getInstance().getSchemaContexts().getProps().<Boolean>getValue(ConfigurationPropertyKey.PROXY_CLUSTER_ENABLED)) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-common/pom.xml b/shardingsphere-proxy/shardingsphere-proxy-common/pom.xml
index 03dff43..651e575 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-common/pom.xml
+++ b/shardingsphere-proxy/shardingsphere-proxy-common/pom.xml
@@ -44,7 +44,7 @@
         </dependency>
         <dependency>
             <groupId>org.apache.shardingsphere</groupId>
-            <artifactId>shardingsphere-metrics-facade</artifactId>
+            <artifactId>shardingsphere-control-panel-spi</artifactId>
             <version>${project.version}</version>
         </dependency>
         <dependency>
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTask.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTask.java
index 4cea0ca..641c500 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTask.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTask.java
@@ -19,15 +19,16 @@ package org.apache.shardingsphere.proxy.frontend.command;
 
 import io.netty.buffer.ByteBuf;
 import io.netty.channel.ChannelHandlerContext;
+import java.util.function.Supplier;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.shardingsphere.control.panel.spi.engine.MetricsHandlerFacadeEngine;
+import org.apache.shardingsphere.control.panel.spi.metrics.MetricsHandlerFacade;
 import org.apache.shardingsphere.db.protocol.packet.CommandPacket;
 import org.apache.shardingsphere.db.protocol.packet.CommandPacketType;
 import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
 import org.apache.shardingsphere.db.protocol.payload.PacketPayload;
-import org.apache.shardingsphere.metrics.api.HistogramMetricsTrackerDelegate;
 import org.apache.shardingsphere.metrics.enums.MetricsLabelEnum;
-import org.apache.shardingsphere.metrics.facade.MetricsTrackerFacade;
 import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
 import org.apache.shardingsphere.proxy.frontend.api.CommandExecutor;
 import org.apache.shardingsphere.proxy.frontend.api.QueryCommandExecutor;
@@ -65,7 +66,11 @@ public final class CommandExecutorTask implements Runnable {
     public void run() {
         RootInvokeHook rootInvokeHook = new SPIRootInvokeHook();
         rootInvokeHook.start();
-        Optional<HistogramMetricsTrackerDelegate> trackerDelegate = MetricsTrackerFacade.getInstance().histogramStartTimer(MetricsLabelEnum.REQUEST_LATENCY.getName());
+        Supplier<Boolean> histogramSupplier = null;
+        Optional<MetricsHandlerFacade> handlerFacade = MetricsHandlerFacadeEngine.build();
+        if (handlerFacade.isPresent()) {
+            histogramSupplier = handlerFacade.get().histogramStartTimer(MetricsLabelEnum.REQUEST_LATENCY.getName());
+        }
         int connectionSize = 0;
         boolean isNeedFlush = false;
         try (BackendConnection backendConnection = this.backendConnection;
@@ -86,7 +91,9 @@ public final class CommandExecutorTask implements Runnable {
                 context.flush();
             }
             rootInvokeHook.finish(connectionSize);
-            trackerDelegate.ifPresent(HistogramMetricsTrackerDelegate::observeDuration);
+            if (null != histogramSupplier) {
+                histogramSupplier.get();
+            }
         }
     }
     
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/netty/FrontendChannelInboundHandler.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/netty/FrontendChannelInboundHandler.java
index 700071d..214fe1d 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/netty/FrontendChannelInboundHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/netty/FrontendChannelInboundHandler.java
@@ -22,10 +22,10 @@ import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.ChannelInboundHandlerAdapter;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.shardingsphere.control.panel.spi.engine.MetricsHandlerFacadeEngine;
 import org.apache.shardingsphere.db.protocol.payload.PacketPayload;
 import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
 import org.apache.shardingsphere.metrics.enums.MetricsLabelEnum;
-import org.apache.shardingsphere.metrics.facade.MetricsTrackerFacade;
 import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
 import org.apache.shardingsphere.proxy.backend.schema.ProxySchemaContexts;
 import org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask;
@@ -55,7 +55,7 @@ public final class FrontendChannelInboundHandler extends ChannelInboundHandlerAd
     public void channelActive(final ChannelHandlerContext context) {
         ChannelThreadExecutorGroup.getInstance().register(context.channel().id());
         databaseProtocolFrontendEngine.getAuthEngine().handshake(context, backendConnection);
-        MetricsTrackerFacade.getInstance().gaugeInc(MetricsLabelEnum.CHANNEL_COUNT.getName());
+        MetricsHandlerFacadeEngine.build().ifPresent(metricsHandlerFacade -> metricsHandlerFacade.gaugeInc(MetricsLabelEnum.CHANNEL_COUNT.getName()));
     }
     
     @Override
@@ -64,7 +64,7 @@ public final class FrontendChannelInboundHandler extends ChannelInboundHandlerAd
             authorized = auth(context, (ByteBuf) message);
             return;
         }
-        MetricsTrackerFacade.getInstance().counterInc(MetricsLabelEnum.REQUEST_TOTAL.getName());
+        MetricsHandlerFacadeEngine.build().ifPresent(metricsHandlerFacade -> metricsHandlerFacade.counterInc(MetricsLabelEnum.REQUEST_TOTAL.getName()));
         CommandExecutorSelector.getExecutor(databaseProtocolFrontendEngine.getFrontendContext().isOccupyThreadForPerConnection(), backendConnection.isSupportHint(),
                 backendConnection.getTransactionType(), context.channel().id()).execute(new CommandExecutorTask(databaseProtocolFrontendEngine, backendConnection, context, message));
     }
@@ -87,7 +87,7 @@ public final class FrontendChannelInboundHandler extends ChannelInboundHandlerAd
         databaseProtocolFrontendEngine.release(backendConnection);
         backendConnection.close(true);
         ChannelThreadExecutorGroup.getInstance().unregister(context.channel().id());
-        MetricsTrackerFacade.getInstance().gaugeDec(MetricsLabelEnum.CHANNEL_COUNT.getName());
+        MetricsHandlerFacadeEngine.build().ifPresent(metricsHandlerFacade -> metricsHandlerFacade.gaugeDec(MetricsLabelEnum.CHANNEL_COUNT.getName()));
     }
     
     @Override