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

albumenj pushed a commit to branch 3.2
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/3.2 by this push:
     new c5938d4873 Metrics Event/Listener refactor (#11982)
c5938d4873 is described below

commit c5938d48731133db9e957d7496470460fbbeac6b
Author: wxbty <[email protected]>
AuthorDate: Tue Apr 4 09:48:04 2023 +0800

    Metrics Event/Listener refactor (#11982)
    
    * Refactor Listener
    
    * remove unuse
    
    * add licence
    
    * add default event available
    
    ---------
    
    Co-authored-by: x-shadow-man <[email protected]>
---
 .../rpc/cluster/directory/AbstractDirectory.java   |  13 +-
 .../org/apache/dubbo/config/ServiceConfig.java     |   2 +-
 .../config/deploy/DefaultApplicationDeployer.java  |   2 +-
 .../apache/dubbo/metrics/event/MethodEvent.java    |   1 +
 .../apache/dubbo/metrics/event/MetricsEvent.java   |   6 +
 .../org/apache/dubbo/metrics/event/RTEvent.java    |   1 +
 ...ption.java => MetricsNeverHappenException.java} |   4 +-
 .../dubbo/metrics/listener/MetricsListener.java    |   2 +-
 .../MetricsLevel.java}                             |   9 +-
 .../apache/dubbo/metrics/model/MetricsSupport.java |   4 +-
 .../{event/RTEvent.java => model/TypeWrapper.java} |  37 ++--
 .../dubbo/metrics/registry/RegistryConstants.java} |  27 ++-
 .../collector/RegistryMetricsCollector.java        |  16 +-
 .../collector/stat/RegistryStatComposite.java      |  39 ++--
 .../registry/event/MetricsDirectoryListener.java   |  43 -----
 .../registry/event/MetricsNotifyListener.java      |  54 ------
 .../registry/event/MetricsRegisterListener.java    |  52 ------
 .../event/MetricsServiceRegisterListener.java      |  51 ------
 .../event/MetricsServiceSubscribeListener.java     |  52 ------
 .../registry/event/MetricsSubscribeListener.java   |  52 ------
 .../metrics/registry/event/RegistryEvent.java      | 202 +++++++--------------
 .../metrics/registry/event/RegistryListener.java   |  67 +++++++
 .../event/RegistryMetricsEventMulticaster.java     | 104 ++++++++++-
 .../registry/event/support/DirectorSupport.java    |  51 ++++++
 .../registry/event/type/ApplicationType.java       |  51 ++++++
 .../metrics/registry/event/type/ServiceType.java}  |  37 ++--
 .../collector/RegistryMetricsCollectorTest.java    |  18 +-
 .../collector/RegistryMetricsSampleTest.java       |  20 +-
 .../collector/RegistryStatCompositeTest.java       |  10 +-
 .../registry/client/ServiceDiscoveryRegistry.java  |   3 +-
 .../listener/ServiceInstancesChangedListener.java  |   4 +-
 .../registry/integration/RegistryDirectory.java    |   2 +-
 32 files changed, 459 insertions(+), 577 deletions(-)

diff --git 
a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/AbstractDirectory.java
 
b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/AbstractDirectory.java
index 21a517202f..8bc44a1479 100644
--- 
a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/AbstractDirectory.java
+++ 
b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/AbstractDirectory.java
@@ -28,7 +28,7 @@ import org.apache.dubbo.common.utils.ConcurrentHashSet;
 import org.apache.dubbo.common.utils.NetUtils;
 import org.apache.dubbo.common.utils.StringUtils;
 import org.apache.dubbo.metrics.event.MetricsEventBus;
-import org.apache.dubbo.metrics.registry.event.RegistryEvent;
+import org.apache.dubbo.metrics.registry.event.support.DirectorSupport;
 import org.apache.dubbo.rpc.Invocation;
 import org.apache.dubbo.rpc.Invoker;
 import org.apache.dubbo.rpc.RpcContext;
@@ -386,7 +386,7 @@ public abstract class AbstractDirectory<T> implements 
Directory<T> {
 
     @Override
     public void addDisabledInvoker(Invoker<T> invoker) {
-        MetricsEventBus.publish(new 
RegistryEvent.MetricsDirectoryEvent(applicationModel, 
RegistryEvent.ApplicationType.D_DISABLE));
+        MetricsEventBus.publish(DirectorSupport.disable(applicationModel));
         if (invokers.contains(invoker)) {
             disabledInvokers.add(invoker);
             removeValidInvoker(invoker);
@@ -396,7 +396,7 @@ public abstract class AbstractDirectory<T> implements 
Directory<T> {
 
     @Override
     public void recoverDisabledInvoker(Invoker<T> invoker) {
-        MetricsEventBus.publish(new 
RegistryEvent.MetricsDirectoryEvent(applicationModel, 
RegistryEvent.ApplicationType.D_RECOVER_DISABLE));
+        MetricsEventBus.publish(DirectorSupport.recover(applicationModel));
         if (disabledInvokers.remove(invoker)) {
             try {
                 addValidInvoker(invoker);
@@ -460,7 +460,8 @@ public abstract class AbstractDirectory<T> implements 
Directory<T> {
         this.invokers = invokers;
         refreshInvokerInternal();
         this.invokersInitialized = true;
-        MetricsEventBus.publish(new 
RegistryEvent.MetricsDirectoryEvent(applicationModel, 
RegistryEvent.ApplicationType.D_CURRENT, invokers.size()));
+
+        
MetricsEventBus.publish(DirectorSupport.current(applicationModel,invokers.size()));
     }
 
     protected void destroyInvokers() {
@@ -471,14 +472,14 @@ public abstract class AbstractDirectory<T> implements 
Directory<T> {
     }
 
     private boolean addValidInvoker(Invoker<T> invoker) {
-        MetricsEventBus.publish(new 
RegistryEvent.MetricsDirectoryEvent(applicationModel, 
RegistryEvent.ApplicationType.D_VALID));
+        MetricsEventBus.publish(DirectorSupport.valid(applicationModel));
         synchronized (this.validInvokers) {
             return this.validInvokers.add(invoker);
         }
     }
 
     private boolean removeValidInvoker(Invoker<T> invoker) {
-        MetricsEventBus.publish(new 
RegistryEvent.MetricsDirectoryEvent(applicationModel, 
RegistryEvent.ApplicationType.D_UN_VALID));
+        MetricsEventBus.publish(DirectorSupport.unValid(applicationModel));
         synchronized (this.validInvokers) {
             return this.validInvokers.remove(invoker);
         }
diff --git 
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java
 
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java
index cc553f569b..7fdc7e7424 100644
--- 
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java
+++ 
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java
@@ -424,7 +424,7 @@ public class ServiceConfig<T> extends ServiceConfigBase<T> {
 
         List<URL> registryURLs = ConfigValidationUtils.loadRegistries(this, 
true);
 
-        MetricsEventBus.post(new 
RegistryEvent.MetricsServiceRegisterEvent(module.getApplicationModel(), 
getUniqueServiceName(), protocols.size() * registryURLs.size()),
+        
MetricsEventBus.post(RegistryEvent.toRsEvent(module.getApplicationModel(), 
getUniqueServiceName(), protocols.size() * registryURLs.size()),
             () -> {
                 for (ProtocolConfig protocolConfig : protocols) {
                     String pathKey = 
URL.buildKey(getContextPath(protocolConfig)
diff --git 
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/deploy/DefaultApplicationDeployer.java
 
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/deploy/DefaultApplicationDeployer.java
index 203fcebe94..07f5358d6e 100644
--- 
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/deploy/DefaultApplicationDeployer.java
+++ 
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/deploy/DefaultApplicationDeployer.java
@@ -860,7 +860,7 @@ public class DefaultApplicationDeployer extends 
AbstractDeployer<ApplicationMode
     private void registerServiceInstance() {
         try {
             registered = true;
-            MetricsEventBus.post(new 
RegistryEvent.MetricsApplicationRegisterEvent(applicationModel),
+            
MetricsEventBus.post(RegistryEvent.toRegisterEvent(applicationModel),
                 () -> {
                     
ServiceInstanceMetadataUtils.registerMetadataAndInstance(applicationModel);
                     return null;
diff --git 
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/MethodEvent.java
 
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/MethodEvent.java
index 59429bf605..3686c03197 100644
--- 
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/MethodEvent.java
+++ 
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/MethodEvent.java
@@ -28,6 +28,7 @@ public class MethodEvent extends MetricsEvent {
         super(applicationModel);
         this.type = type;
         this.methodMetric = methodMetric;
+        setAvailable(true);
     }
 
     public MethodMetric getMethodMetric() {
diff --git 
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/MetricsEvent.java
 
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/MetricsEvent.java
index 957a5a9f3b..957771432b 100644
--- 
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/MetricsEvent.java
+++ 
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/MetricsEvent.java
@@ -18,6 +18,7 @@
 package org.apache.dubbo.metrics.event;
 
 import org.apache.dubbo.metrics.model.MethodMetric;
+import org.apache.dubbo.metrics.model.TypeWrapper;
 import org.apache.dubbo.rpc.model.ApplicationModel;
 
 /**
@@ -30,6 +31,7 @@ public abstract class MetricsEvent {
      */
     protected transient ApplicationModel source;
     private boolean available = true;
+    protected TypeWrapper typeWrapper;
 
     @SuppressWarnings({"unchecked"})
     public MetricsEvent(ApplicationModel source) {
@@ -59,6 +61,10 @@ public abstract class MetricsEvent {
         return source;
     }
 
+    public boolean isAssignableFrom(Object type) {
+        return typeWrapper.isAssignableFrom(type);
+    }
+
     public String toString() {
         return getClass().getName() + "[source=" + source + "]";
     }
diff --git 
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/RTEvent.java
 
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/RTEvent.java
index bd4f53c901..18256ffda4 100644
--- 
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/RTEvent.java
+++ 
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/RTEvent.java
@@ -30,6 +30,7 @@ public class RTEvent extends MetricsEvent {
         super(applicationModel);
         this.rt = rt;
         this.metric = metric;
+        setAvailable(true);
     }
 
     public Long getRt() {
diff --git 
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/exception/MetricsException.java
 
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/exception/MetricsNeverHappenException.java
similarity index 87%
copy from 
dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/exception/MetricsException.java
copy to 
dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/exception/MetricsNeverHappenException.java
index 20f238abde..1f5336611b 100644
--- 
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/exception/MetricsException.java
+++ 
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/exception/MetricsNeverHappenException.java
@@ -17,9 +17,9 @@
 
 package org.apache.dubbo.metrics.exception;
 
-public class MetricsException extends RuntimeException {
+public class MetricsNeverHappenException extends RuntimeException {
 
-    public MetricsException(String message) {
+    public MetricsNeverHappenException(String message) {
         super(message);
     }
 }
diff --git 
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/listener/MetricsListener.java
 
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/listener/MetricsListener.java
index 64b4796af3..8f0926796e 100644
--- 
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/listener/MetricsListener.java
+++ 
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/listener/MetricsListener.java
@@ -25,7 +25,7 @@ import org.apache.dubbo.metrics.event.MetricsEvent;
 public interface MetricsListener<E extends MetricsEvent> {
 
     default boolean isSupport(MetricsEvent event) {
-        return true;
+        return event.isAvailable();
     }
 
     /**
diff --git 
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/exception/MetricsException.java
 
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/MetricsLevel.java
similarity index 81%
rename from 
dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/exception/MetricsException.java
rename to 
dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/MetricsLevel.java
index 20f238abde..adec8f54f0 100644
--- 
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/exception/MetricsException.java
+++ 
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/MetricsLevel.java
@@ -15,11 +15,8 @@
  * limitations under the License.
  */
 
-package org.apache.dubbo.metrics.exception;
+package org.apache.dubbo.metrics.model;
 
-public class MetricsException extends RuntimeException {
-
-    public MetricsException(String message) {
-        super(message);
-    }
+public enum MetricsLevel {
+    APP,SERVICE
 }
diff --git 
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/MetricsSupport.java
 
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/MetricsSupport.java
index f6820a64b9..68aed196e0 100644
--- 
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/MetricsSupport.java
+++ 
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/MetricsSupport.java
@@ -18,7 +18,7 @@
 package org.apache.dubbo.metrics.model;
 
 import org.apache.dubbo.common.Version;
-import org.apache.dubbo.metrics.exception.MetricsException;
+import org.apache.dubbo.metrics.exception.MetricsNeverHappenException;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -49,7 +49,7 @@ public class MetricsSupport {
     public static Map<String, String> serviceTags(String appAndServiceName) {
         String[] keys = appAndServiceName.split("_");
         if (keys.length != 2) {
-            throw new MetricsException("Error service name: " + 
appAndServiceName);
+            throw new MetricsNeverHappenException("Error service name: " + 
appAndServiceName);
         }
         Map<String, String> tags = applicationTags(keys[0]);
         tags.put(TAG_INTERFACE_KEY, keys[1]);
diff --git 
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/RTEvent.java
 
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/TypeWrapper.java
similarity index 50%
copy from 
dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/RTEvent.java
copy to 
dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/TypeWrapper.java
index bd4f53c901..765569d40d 100644
--- 
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/RTEvent.java
+++ 
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/TypeWrapper.java
@@ -15,32 +15,33 @@
  * limitations under the License.
  */
 
-package org.apache.dubbo.metrics.event;
+package org.apache.dubbo.metrics.model;
 
-import org.apache.dubbo.rpc.model.ApplicationModel;
+import org.apache.dubbo.common.utils.Assert;
 
-/**
- * RtEvent.
- */
-public class RTEvent extends MetricsEvent {
-    private Long rt;
-    private final Object metric;
+public class TypeWrapper {
+    private final MetricsLevel level;
+    private final Object postType;
+    private final Object finishType;
+    private final Object errorType;
 
-    public RTEvent(ApplicationModel applicationModel, Object metric, Long rt) {
-        super(applicationModel);
-        this.rt = rt;
-        this.metric = metric;
+    public TypeWrapper(MetricsLevel level, Object postType, Object finishType, 
Object errorType) {
+        this.level = level;
+        this.postType = postType;
+        this.finishType = finishType;
+        this.errorType = errorType;
     }
 
-    public Long getRt() {
-        return rt;
+    public MetricsLevel getLevel() {
+        return level;
     }
 
-    public void setRt(Long rt) {
-        this.rt = rt;
+    public Object getErrorType() {
+        return errorType;
     }
 
-    public Object getMetric() {
-        return metric;
+    public boolean isAssignableFrom(Object type) {
+        Assert.notNull(type, "Type can not be null");
+        return type.equals(postType) || type.equals(finishType) || 
type.equals(errorType);
     }
 }
diff --git 
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/listener/MetricsListener.java
 
b/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/RegistryConstants.java
similarity index 61%
copy from 
dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/listener/MetricsListener.java
copy to 
dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/RegistryConstants.java
index 64b4796af3..341ee385f9 100644
--- 
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/listener/MetricsListener.java
+++ 
b/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/RegistryConstants.java
@@ -15,25 +15,20 @@
  * limitations under the License.
  */
 
-package org.apache.dubbo.metrics.listener;
+package org.apache.dubbo.metrics.registry;
 
-import org.apache.dubbo.metrics.event.MetricsEvent;
+public interface RegistryConstants {
 
-/**
- * Metrics Listener.
- */
-public interface MetricsListener<E extends MetricsEvent> {
+    String ATTACHMENT_KEY_SERVICE = "serviceKey";
+    String ATTACHMENT_KEY_SIZE = "size";
+    String ATTACHMENT_KEY_LAST_NUM_MAP = "lastNumMap";
+    String ATTACHMENT_KEY_DIR_NUM = "dirNum";
 
-    default boolean isSupport(MetricsEvent event) {
-        return true;
-    }
+    String OP_TYPE_REGISTER = "register";
+    String OP_TYPE_SUBSCRIBE = "subscribe";
+    String OP_TYPE_NOTIFY = "notify";
+    String OP_TYPE_REGISTER_SERVICE = "register.service";
+    String OP_TYPE_SUBSCRIBE_SERVICE = "subscribe.service";
 
-    /**
-     * notify event.
-     *
-     * @param event BaseMetricsEvent
-     */
-    default void onEvent(E event) {
-    }
 
 }
diff --git 
a/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/collector/RegistryMetricsCollector.java
 
b/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/collector/RegistryMetricsCollector.java
index 0d7aa66d7a..84a1ee3d6d 100644
--- 
a/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/collector/RegistryMetricsCollector.java
+++ 
b/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/collector/RegistryMetricsCollector.java
@@ -27,6 +27,8 @@ import org.apache.dubbo.metrics.model.sample.MetricSample;
 import org.apache.dubbo.metrics.registry.collector.stat.RegistryStatComposite;
 import org.apache.dubbo.metrics.registry.event.RegistryEvent;
 import org.apache.dubbo.metrics.registry.event.RegistryMetricsEventMulticaster;
+import org.apache.dubbo.metrics.registry.event.type.ApplicationType;
+import org.apache.dubbo.metrics.registry.event.type.ServiceType;
 import org.apache.dubbo.rpc.model.ApplicationModel;
 
 import java.util.ArrayList;
@@ -39,7 +41,7 @@ import java.util.Optional;
  * Registry implementation of {@link MetricsCollector}
  */
 @Activate
-public class RegistryMetricsCollector implements 
ApplicationMetricsCollector<RegistryEvent.ApplicationType, RegistryEvent> {
+public class RegistryMetricsCollector implements 
ApplicationMetricsCollector<ApplicationType, RegistryEvent> {
 
     private Boolean collectEnabled = null;
     private final RegistryStatComposite stats;
@@ -67,26 +69,22 @@ public class RegistryMetricsCollector implements 
ApplicationMetricsCollector<Reg
         return Optional.ofNullable(collectEnabled).orElse(true);
     }
 
-    public void setNum(RegistryEvent.ServiceType registryType, String 
applicationName, Map<String, Integer> lastNumMap) {
+    public void setNum(ServiceType registryType, String applicationName, 
Map<String, Integer> lastNumMap) {
         lastNumMap.forEach((serviceKey, num) ->
             this.stats.setServiceKey(registryType, applicationName, 
serviceKey, num));
     }
 
-    public void setNum(RegistryEvent.ApplicationType registryType, String 
applicationName, Integer num) {
+    public void setNum(ApplicationType registryType, String applicationName, 
Integer num) {
         this.stats.setApplicationKey(registryType, applicationName, num);
     }
 
 
     @Override
-    public void increment(String applicationName, 
RegistryEvent.ApplicationType registryType) {
+    public void increment(String applicationName, ApplicationType 
registryType) {
         this.stats.increment(registryType, applicationName);
     }
 
-    public void increment(String applicationName, 
RegistryEvent.ApplicationType registryType, int size) {
-        this.stats.incrementSize(registryType, applicationName, size);
-    }
-
-    public void incrementServiceKey(String applicationName, String serviceKey, 
RegistryEvent.ServiceType registryType, int size) {
+    public void incrementServiceKey(String applicationName, String serviceKey, 
ServiceType registryType, int size) {
         this.stats.incrementServiceKey(registryType, applicationName, 
serviceKey, size);
     }
 
diff --git 
a/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/collector/stat/RegistryStatComposite.java
 
b/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/collector/stat/RegistryStatComposite.java
index 2c78106b66..5c046ec5ee 100644
--- 
a/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/collector/stat/RegistryStatComposite.java
+++ 
b/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/collector/stat/RegistryStatComposite.java
@@ -28,7 +28,8 @@ import 
org.apache.dubbo.metrics.model.container.AtomicLongContainer;
 import org.apache.dubbo.metrics.model.container.LongAccumulatorContainer;
 import org.apache.dubbo.metrics.model.container.LongContainer;
 import org.apache.dubbo.metrics.model.sample.GaugeMetricSample;
-import org.apache.dubbo.metrics.registry.event.RegistryEvent;
+import org.apache.dubbo.metrics.registry.event.type.ApplicationType;
+import org.apache.dubbo.metrics.registry.event.type.ServiceType;
 import org.apache.dubbo.metrics.report.MetricsExport;
 
 import java.util.ArrayList;
@@ -39,6 +40,12 @@ import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.atomic.LongAccumulator;
 import java.util.stream.Collectors;
 
+import static 
org.apache.dubbo.metrics.registry.RegistryConstants.OP_TYPE_NOTIFY;
+import static 
org.apache.dubbo.metrics.registry.RegistryConstants.OP_TYPE_REGISTER;
+import static 
org.apache.dubbo.metrics.registry.RegistryConstants.OP_TYPE_REGISTER_SERVICE;
+import static 
org.apache.dubbo.metrics.registry.RegistryConstants.OP_TYPE_SUBSCRIBE;
+import static 
org.apache.dubbo.metrics.registry.RegistryConstants.OP_TYPE_SUBSCRIBE_SERVICE;
+
 /**
  * As a data aggregator, use internal data containers calculates and classifies
  * the registry data collected by {@link MetricsCollector MetricsCollector}, 
and
@@ -46,23 +53,17 @@ import java.util.stream.Collectors;
  */
 public class RegistryStatComposite implements MetricsExport {
 
-
-    public Map<RegistryEvent.ApplicationType, Map<String, AtomicLong>> 
applicationNumStats = new ConcurrentHashMap<>();
-    public Map<RegistryEvent.ServiceType, Map<ServiceKeyMetric, AtomicLong>> 
serviceNumStats = new ConcurrentHashMap<>();
+    public Map<ApplicationType, Map<String, AtomicLong>> applicationNumStats = 
new ConcurrentHashMap<>();
+    public Map<ServiceType, Map<ServiceKeyMetric, AtomicLong>> serviceNumStats 
= new ConcurrentHashMap<>();
     public List<LongContainer<? extends Number>> rtStats = new ArrayList<>();
-    public static String OP_TYPE_REGISTER = "register";
-    public static String OP_TYPE_SUBSCRIBE = "subscribe";
-    public static String OP_TYPE_NOTIFY = "notify";
-    public static String OP_TYPE_REGISTER_SERVICE = "register.service";
-    public static String OP_TYPE_SUBSCRIBE_SERVICE = "subscribe.service";
 
     public RegistryStatComposite() {
-        for (RegistryEvent.ApplicationType type : 
RegistryEvent.ApplicationType.values()) {
+        for (ApplicationType type : ApplicationType.values()) {
             // Application key and increment val
             applicationNumStats.put(type, new ConcurrentHashMap<>());
         }
 
-        for (RegistryEvent.ServiceType type : 
RegistryEvent.ServiceType.values()) {
+        for (ServiceType type : ServiceType.values()) {
             // Service key
             serviceNumStats.put(type, new ConcurrentHashMap<>());
         }
@@ -95,32 +96,32 @@ public class RegistryStatComposite implements MetricsExport 
{
         return singleRtStats;
     }
 
-    public void setApplicationKey(RegistryEvent.ApplicationType type, String 
applicationName, int num) {
+    public void setApplicationKey(ApplicationType type, String 
applicationName, int num) {
         if (!applicationNumStats.containsKey(type)) {
             return;
         }
         applicationNumStats.get(type).computeIfAbsent(applicationName, k -> 
new AtomicLong(0L)).set(num);
     }
 
-    public void setServiceKey(RegistryEvent.ServiceType type, String 
applicationName, String serviceKey, int num) {
+    public void setServiceKey(ServiceType type, String applicationName, String 
serviceKey, int num) {
         if (!serviceNumStats.containsKey(type)) {
             return;
         }
         serviceNumStats.get(type).computeIfAbsent(new 
ServiceKeyMetric(applicationName, serviceKey), k -> new 
AtomicLong(0L)).set(num);
     }
 
-    public void increment(RegistryEvent.ApplicationType type, String 
applicationName) {
+    public void increment(ApplicationType type, String applicationName) {
         incrementSize(type, applicationName, 1);
     }
 
-    public void incrementServiceKey(RegistryEvent.ServiceType type, String 
applicationName, String serviceKey, int size) {
+    public void incrementServiceKey(ServiceType type, String applicationName, 
String serviceKey, int size) {
         if (!serviceNumStats.containsKey(type)) {
             return;
         }
         serviceNumStats.get(type).computeIfAbsent(new 
ServiceKeyMetric(applicationName, serviceKey), k -> new 
AtomicLong(0L)).getAndAdd(size);
     }
 
-    public void incrementSize(RegistryEvent.ApplicationType type, String 
applicationName, int size) {
+    public void incrementSize(ApplicationType type, String applicationName, 
int size) {
         if (!applicationNumStats.containsKey(type)) {
             return;
         }
@@ -147,7 +148,7 @@ public class RegistryStatComposite implements MetricsExport 
{
     @SuppressWarnings({"rawtypes"})
     public List<GaugeMetricSample> exportNumMetrics() {
         List<GaugeMetricSample> list = new ArrayList<>();
-        for (RegistryEvent.ApplicationType type : 
applicationNumStats.keySet()) {
+        for (ApplicationType type : applicationNumStats.keySet()) {
             Map<String, AtomicLong> stringAtomicLongMap = 
applicationNumStats.get(type);
             for (String applicationName : stringAtomicLongMap.keySet()) {
                 list.add(convertToSample(applicationName, type, 
MetricsCategory.REGISTRY, stringAtomicLongMap.get(applicationName)));
@@ -177,7 +178,7 @@ public class RegistryStatComposite implements MetricsExport 
{
     @SuppressWarnings({"rawtypes"})
     public List<GaugeMetricSample> exportSkMetrics() {
         List<GaugeMetricSample> list = new ArrayList<>();
-        for (RegistryEvent.ServiceType type : serviceNumStats.keySet()) {
+        for (ServiceType type : serviceNumStats.keySet()) {
             Map<ServiceKeyMetric, AtomicLong> stringAtomicLongMap = 
serviceNumStats.get(type);
             for (ServiceKeyMetric serviceKeyMetric : 
stringAtomicLongMap.keySet()) {
                 list.add(new GaugeMetricSample<>(type.getMetricsKey(), 
serviceKeyMetric.getTags(), MetricsCategory.REGISTRY, stringAtomicLongMap, 
value -> value.get(serviceKeyMetric).get()));
@@ -187,7 +188,7 @@ public class RegistryStatComposite implements MetricsExport 
{
     }
 
     @SuppressWarnings({"rawtypes"})
-    public GaugeMetricSample convertToSample(String applicationName, 
RegistryEvent.ApplicationType type, MetricsCategory category, AtomicLong 
targetNumber) {
+    public GaugeMetricSample convertToSample(String applicationName, 
ApplicationType type, MetricsCategory category, AtomicLong targetNumber) {
         return new GaugeMetricSample<>(type.getMetricsKey(), 
MetricsSupport.applicationTags(applicationName), category, targetNumber, 
AtomicLong::get);
     }
 }
diff --git 
a/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/MetricsDirectoryListener.java
 
b/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/MetricsDirectoryListener.java
deleted file mode 100644
index 27648f962d..0000000000
--- 
a/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/MetricsDirectoryListener.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.dubbo.metrics.registry.event;
-
-import org.apache.dubbo.metrics.event.MetricsEvent;
-import org.apache.dubbo.metrics.listener.MetricsListener;
-
-public class MetricsDirectoryListener implements 
MetricsListener<RegistryEvent.MetricsDirectoryEvent> {
-
-    @Override
-    public boolean isSupport(MetricsEvent event) {
-        return event instanceof RegistryEvent.MetricsDirectoryEvent;
-    }
-
-    @Override
-    public void onEvent(RegistryEvent.MetricsDirectoryEvent event) {
-        if (!event.isAvailable()) {
-            return;
-        }
-        if (event.getType().isIncrement()) {
-            
event.getCollector().increment(event.getSource().getApplicationName(), 
event.getType());
-        } else {
-            event.getCollector().setNum(event.getType(), 
event.getSource().getApplicationName(), event.getSize());
-        }
-    }
-
-
-}
diff --git 
a/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/MetricsNotifyListener.java
 
b/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/MetricsNotifyListener.java
deleted file mode 100644
index 6dd7828faf..0000000000
--- 
a/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/MetricsNotifyListener.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.dubbo.metrics.registry.event;
-
-import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
-import org.apache.dubbo.common.logger.LoggerFactory;
-import org.apache.dubbo.metrics.event.MetricsEvent;
-import org.apache.dubbo.metrics.listener.MetricsLifeListener;
-
-import static 
org.apache.dubbo.metrics.registry.collector.stat.RegistryStatComposite.OP_TYPE_NOTIFY;
-
-/**
- * The registration center actively pushes Listener, no failure and rt 
statistics
- */
-public class MetricsNotifyListener implements 
MetricsLifeListener<RegistryEvent.MetricsNotifyEvent> {
-
-    protected final ErrorTypeAwareLogger logger = 
LoggerFactory.getErrorTypeAwareLogger(getClass());
-
-    @Override
-    public boolean isSupport(MetricsEvent event) {
-        return event instanceof RegistryEvent.MetricsNotifyEvent;
-    }
-
-    @Override
-    public void onEvent(RegistryEvent.MetricsNotifyEvent event) {
-        event.getCollector().increment(event.getSource().getApplicationName(), 
RegistryEvent.ApplicationType.N_TOTAL);
-    }
-
-    @Override
-    public void onEventFinish(RegistryEvent.MetricsNotifyEvent event) {
-        event.getCollector().setNum(RegistryEvent.ServiceType.N_LAST_NUM, 
event.getSource().getApplicationName(), event.getLastNotifyNum());
-        
event.getCollector().addApplicationRT(event.getSource().getApplicationName(), 
OP_TYPE_NOTIFY, event.getTimePair().calc());
-    }
-
-    @Override
-    public void onEventError(RegistryEvent.MetricsNotifyEvent event) {
-    }
-
-}
diff --git 
a/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/MetricsRegisterListener.java
 
b/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/MetricsRegisterListener.java
deleted file mode 100644
index 8fbe835a37..0000000000
--- 
a/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/MetricsRegisterListener.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.dubbo.metrics.registry.event;
-
-import org.apache.dubbo.metrics.event.MetricsEvent;
-import org.apache.dubbo.metrics.listener.MetricsLifeListener;
-
-import static 
org.apache.dubbo.metrics.registry.collector.stat.RegistryStatComposite.OP_TYPE_REGISTER;
-
-public class MetricsRegisterListener implements 
MetricsLifeListener<RegistryEvent.MetricsApplicationRegisterEvent> {
-
-
-    @Override
-    public boolean isSupport(MetricsEvent event) {
-        return event instanceof RegistryEvent.MetricsApplicationRegisterEvent;
-    }
-
-    @Override
-    public void onEvent(RegistryEvent.MetricsApplicationRegisterEvent event) {
-        if (!event.isAvailable()) {
-            return;
-        }
-        event.getCollector().increment(event.getSource().getApplicationName(), 
RegistryEvent.ApplicationType.R_TOTAL);
-    }
-
-    @Override
-    public void onEventFinish(RegistryEvent.MetricsApplicationRegisterEvent 
event) {
-        event.getCollector().increment(event.getSource().getApplicationName(), 
RegistryEvent.ApplicationType.R_SUCCEED);
-        
event.getCollector().addApplicationRT(event.getSource().getApplicationName(), 
OP_TYPE_REGISTER, event.getTimePair().calc());
-    }
-
-    @Override
-    public void onEventError(RegistryEvent.MetricsApplicationRegisterEvent 
event) {
-        event.getCollector().increment(event.getSource().getApplicationName(), 
RegistryEvent.ApplicationType.R_FAILED);
-        
event.getCollector().addApplicationRT(event.getSource().getApplicationName(), 
OP_TYPE_REGISTER, event.getTimePair().calc());
-    }
-}
diff --git 
a/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/MetricsServiceRegisterListener.java
 
b/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/MetricsServiceRegisterListener.java
deleted file mode 100644
index 45aba8c226..0000000000
--- 
a/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/MetricsServiceRegisterListener.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.dubbo.metrics.registry.event;
-
-import org.apache.dubbo.metrics.event.MetricsEvent;
-import org.apache.dubbo.metrics.listener.MetricsLifeListener;
-
-import static 
org.apache.dubbo.metrics.registry.collector.stat.RegistryStatComposite.OP_TYPE_REGISTER_SERVICE;
-
-public class MetricsServiceRegisterListener implements 
MetricsLifeListener<RegistryEvent.MetricsServiceRegisterEvent> {
-
-    @Override
-    public boolean isSupport(MetricsEvent event) {
-        return event instanceof RegistryEvent.MetricsServiceRegisterEvent;
-    }
-
-    @Override
-    public void onEvent(RegistryEvent.MetricsServiceRegisterEvent event) {
-        if (!event.isAvailable()) {
-            return;
-        }
-        
event.getCollector().incrementServiceKey(event.getSource().getApplicationName(),
 event.getServiceKey(), RegistryEvent.ServiceType.R_SERVICE_TOTAL, 
event.getSize());
-    }
-
-    @Override
-    public void onEventFinish(RegistryEvent.MetricsServiceRegisterEvent event) 
{
-        
event.getCollector().incrementServiceKey(event.getSource().getApplicationName(),
 event.getServiceKey(), RegistryEvent.ServiceType.R_SERVICE_SUCCEED, 
event.getSize());
-        
event.getCollector().addServiceKeyRT(event.getSource().getApplicationName(), 
event.getServiceKey(), OP_TYPE_REGISTER_SERVICE, event.getTimePair().calc());
-    }
-
-    @Override
-    public void onEventError(RegistryEvent.MetricsServiceRegisterEvent event) {
-        
event.getCollector().incrementServiceKey(event.getSource().getApplicationName(),
 event.getServiceKey(), RegistryEvent.ServiceType.R_SERVICE_FAILED, 
event.getSize());
-        
event.getCollector().addServiceKeyRT(event.getSource().getApplicationName(),event.getServiceKey(),
 OP_TYPE_REGISTER_SERVICE, event.getTimePair().calc());
-    }
-}
diff --git 
a/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/MetricsServiceSubscribeListener.java
 
b/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/MetricsServiceSubscribeListener.java
deleted file mode 100644
index 7e1265551f..0000000000
--- 
a/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/MetricsServiceSubscribeListener.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.dubbo.metrics.registry.event;
-
-import org.apache.dubbo.metrics.event.MetricsEvent;
-import org.apache.dubbo.metrics.listener.MetricsLifeListener;
-
-import static 
org.apache.dubbo.metrics.registry.collector.stat.RegistryStatComposite.OP_TYPE_SUBSCRIBE_SERVICE;
-
-public class MetricsServiceSubscribeListener implements 
MetricsLifeListener<RegistryEvent.MetricsServiceSubscribeEvent> {
-
-    @Override
-    public boolean isSupport(MetricsEvent event) {
-        return event instanceof RegistryEvent.MetricsServiceSubscribeEvent;
-    }
-
-    @Override
-    public void onEvent(RegistryEvent.MetricsServiceSubscribeEvent event) {
-        if (!event.isAvailable()) {
-            return;
-        }
-        
event.getCollector().incrementServiceKey(event.getSource().getApplicationName(),
 event.getUniqueServiceName(), RegistryEvent.ServiceType.S_SERVICE_TOTAL, 1);
-    }
-
-    @Override
-    public void onEventFinish(RegistryEvent.MetricsServiceSubscribeEvent 
event) {
-        
event.getCollector().incrementServiceKey(event.getSource().getApplicationName(),
 event.getUniqueServiceName(), RegistryEvent.ServiceType.S_SERVICE_SUCCEED, 1);
-        
event.getCollector().addServiceKeyRT(event.getSource().getApplicationName(), 
event.getUniqueServiceName(), OP_TYPE_SUBSCRIBE_SERVICE, 
event.getTimePair().calc());
-    }
-
-    @Override
-    public void onEventError(RegistryEvent.MetricsServiceSubscribeEvent event) 
{
-        
event.getCollector().incrementServiceKey(event.getSource().getApplicationName(),
 event.getUniqueServiceName(), RegistryEvent.ServiceType.S_SERVICE_FAILED, 1);
-        
event.getCollector().addServiceKeyRT(event.getSource().getApplicationName(), 
event.getUniqueServiceName(), OP_TYPE_SUBSCRIBE_SERVICE, 
event.getTimePair().calc());
-    }
-
-}
diff --git 
a/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/MetricsSubscribeListener.java
 
b/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/MetricsSubscribeListener.java
deleted file mode 100644
index 1caf41c489..0000000000
--- 
a/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/MetricsSubscribeListener.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.dubbo.metrics.registry.event;
-
-import org.apache.dubbo.metrics.event.MetricsEvent;
-import org.apache.dubbo.metrics.listener.MetricsLifeListener;
-
-import static 
org.apache.dubbo.metrics.registry.collector.stat.RegistryStatComposite.OP_TYPE_SUBSCRIBE;
-
-public class MetricsSubscribeListener implements 
MetricsLifeListener<RegistryEvent.MetricsSubscribeEvent> {
-
-    @Override
-    public boolean isSupport(MetricsEvent event) {
-        return event instanceof RegistryEvent.MetricsSubscribeEvent;
-    }
-
-    @Override
-    public void onEvent(RegistryEvent.MetricsSubscribeEvent event) {
-        if (!event.isAvailable()) {
-            return;
-        }
-        event.getCollector().increment(event.getSource().getApplicationName(), 
RegistryEvent.ApplicationType.S_TOTAL);
-    }
-
-    @Override
-    public void onEventFinish(RegistryEvent.MetricsSubscribeEvent event) {
-        event.getCollector().increment(event.getSource().getApplicationName(), 
RegistryEvent.ApplicationType.S_SUCCEED);
-        
event.getCollector().addApplicationRT(event.getSource().getApplicationName(), 
OP_TYPE_SUBSCRIBE, event.getTimePair().calc());
-    }
-
-    @Override
-    public void onEventError(RegistryEvent.MetricsSubscribeEvent event) {
-        event.getCollector().increment(event.getSource().getApplicationName(), 
RegistryEvent.ApplicationType.S_FAILED);
-        
event.getCollector().addApplicationRT(event.getSource().getApplicationName(), 
OP_TYPE_SUBSCRIBE, event.getTimePair().calc());
-    }
-
-}
diff --git 
a/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/RegistryEvent.java
 
b/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/RegistryEvent.java
index c9687df37a..8b7164ea4a 100644
--- 
a/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/RegistryEvent.java
+++ 
b/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/RegistryEvent.java
@@ -19,20 +19,31 @@ package org.apache.dubbo.metrics.registry.event;
 
 import org.apache.dubbo.common.beans.factory.ScopeBeanFactory;
 import org.apache.dubbo.metrics.event.TimeCounterEvent;
-import org.apache.dubbo.metrics.model.MetricsKey;
+import org.apache.dubbo.metrics.exception.MetricsNeverHappenException;
+import org.apache.dubbo.metrics.model.MetricsLevel;
+import org.apache.dubbo.metrics.model.TypeWrapper;
 import org.apache.dubbo.metrics.registry.collector.RegistryMetricsCollector;
+import org.apache.dubbo.metrics.registry.event.type.ApplicationType;
+import org.apache.dubbo.metrics.registry.event.type.ServiceType;
 import org.apache.dubbo.rpc.model.ApplicationModel;
 
+import java.util.HashMap;
 import java.util.Map;
 
+import static 
org.apache.dubbo.metrics.registry.RegistryConstants.ATTACHMENT_KEY_LAST_NUM_MAP;
+import static 
org.apache.dubbo.metrics.registry.RegistryConstants.ATTACHMENT_KEY_SERVICE;
+import static 
org.apache.dubbo.metrics.registry.RegistryConstants.ATTACHMENT_KEY_SIZE;
+
 /**
  * Registry related events
  */
 public class RegistryEvent extends TimeCounterEvent {
     private final RegistryMetricsCollector collector;
+    protected Map<String, Object> attachment = new HashMap<>(8);
 
-    public RegistryEvent(ApplicationModel applicationModel) {
+    public RegistryEvent(ApplicationModel applicationModel, TypeWrapper 
typeWrapper) {
         super(applicationModel);
+        super.typeWrapper = typeWrapper;
         ScopeBeanFactory beanFactory = getSource().getBeanFactory();
         if (beanFactory.isDestroyed()) {
             this.collector = null;
@@ -42,180 +53,93 @@ public class RegistryEvent extends TimeCounterEvent {
         }
     }
 
+
     public ApplicationModel getSource() {
-        return (ApplicationModel) source;
+        return source;
     }
 
     public RegistryMetricsCollector getCollector() {
         return collector;
     }
 
-
-    public enum ApplicationType {
-        R_TOTAL(MetricsKey.REGISTER_METRIC_REQUESTS),
-        R_SUCCEED(MetricsKey.REGISTER_METRIC_REQUESTS_SUCCEED),
-        R_FAILED(MetricsKey.REGISTER_METRIC_REQUESTS_FAILED),
-
-        S_TOTAL(MetricsKey.SUBSCRIBE_METRIC_NUM),
-        S_SUCCEED(MetricsKey.SUBSCRIBE_METRIC_NUM_SUCCEED),
-        S_FAILED(MetricsKey.SUBSCRIBE_METRIC_NUM_FAILED),
-
-        D_VALID(MetricsKey.DIRECTORY_METRIC_NUM_VALID),
-        D_UN_VALID(MetricsKey.DIRECTORY_METRIC_NUM_UN_VALID),
-        D_DISABLE(MetricsKey.DIRECTORY_METRIC_NUM_DISABLE),
-        D_CURRENT(MetricsKey.DIRECTORY_METRIC_NUM_CURRENT, false),
-        D_RECOVER_DISABLE(MetricsKey.DIRECTORY_METRIC_NUM_RECOVER_DISABLE),
-
-        N_TOTAL(MetricsKey.NOTIFY_METRIC_REQUESTS),
-        ;
-
-        private final MetricsKey metricsKey;
-        private final boolean isIncrement;
-
-
-        ApplicationType(MetricsKey metricsKey) {
-            this(metricsKey, true);
-        }
-
-        ApplicationType(MetricsKey metricsKey, boolean isIncrement) {
-            this.metricsKey = metricsKey;
-            this.isIncrement = isIncrement;
-        }
-
-        public MetricsKey getMetricsKey() {
-            return metricsKey;
-        }
-
-        public boolean isIncrement() {
-            return isIncrement;
+    @SuppressWarnings("unchecked")
+    public <T> T getAttachmentValue(String key) {
+        if (!attachment.containsKey(key)) {
+            throw new MetricsNeverHappenException("Attachment key [" + key + 
"] not found");
         }
+        return (T) attachment.get(key);
     }
 
-    public enum ServiceType {
-
-        N_LAST_NUM(MetricsKey.NOTIFY_METRIC_NUM_LAST),
+    public void putAttachment(String key, Object value) {
+        attachment.put(key, value);
+    }
 
-        R_SERVICE_TOTAL(MetricsKey.SERVICE_REGISTER_METRIC_REQUESTS),
-        R_SERVICE_SUCCEED(MetricsKey.SERVICE_REGISTER_METRIC_REQUESTS_SUCCEED),
-        R_SERVICE_FAILED(MetricsKey.SERVICE_REGISTER_METRIC_REQUESTS_FAILED),
 
-        S_SERVICE_TOTAL(MetricsKey.SERVICE_SUBSCRIBE_METRIC_NUM),
-        S_SERVICE_SUCCEED(MetricsKey.SERVICE_SUBSCRIBE_METRIC_NUM_SUCCEED),
-        S_SERVICE_FAILED(MetricsKey.SERVICE_SUBSCRIBE_METRIC_NUM_FAILED),
-        ;
 
-        private final MetricsKey metricsKey;
-        private final boolean isIncrement;
 
 
-        ServiceType(MetricsKey metricsKey) {
-            this(metricsKey, true);
-        }
 
-        ServiceType(MetricsKey metricsKey, boolean isIncrement) {
-            this.metricsKey = metricsKey;
-            this.isIncrement = isIncrement;
-        }
-
-        public MetricsKey getMetricsKey() {
-            return metricsKey;
-        }
-
-        public boolean isIncrement() {
-            return isIncrement;
-        }
+    public void setLastNum(ServiceType type) {
+        getCollector().setNum(type, getSource().getApplicationName(), 
getAttachmentValue(ATTACHMENT_KEY_LAST_NUM_MAP));
     }
 
-    public static class MetricsApplicationRegisterEvent extends RegistryEvent {
-
-        public MetricsApplicationRegisterEvent(ApplicationModel 
applicationModel) {
-            super(applicationModel);
-        }
+    public void addApplicationRT(String opType) {
+        getCollector().addApplicationRT(getSource().getApplicationName(), 
opType, getTimePair().calc());
 
     }
 
-    public static class MetricsSubscribeEvent extends RegistryEvent {
-
-        public MetricsSubscribeEvent(ApplicationModel applicationModel) {
-            super(applicationModel);
-        }
-
+    public void setNum(ApplicationType type, String attachmentKey) {
+        getCollector().setNum(type, getSource().getApplicationName(), 
getAttachmentValue(attachmentKey));
     }
 
-    public static class MetricsNotifyEvent extends RegistryEvent {
-
-        private Map<String, Integer> lastNumMap;
-
-        public MetricsNotifyEvent(ApplicationModel applicationModel) {
-            super(applicationModel);
-        }
-
-        public Map<String, Integer> getLastNotifyNum() {
-            return lastNumMap;
-        }
-
-        @Override
-        @SuppressWarnings("unchecked")
-        public void customAfterPost(Object postResult) {
-            this.lastNumMap = (Map<String, Integer>) postResult;
-        }
+    public void incrementServiceKey(ServiceType type, String attServiceKey, 
String attSize) {
+        incrementServiceKey(type, attServiceKey, (int) 
getAttachmentValue(attSize));
     }
 
-    public static class MetricsDirectoryEvent extends RegistryEvent {
-
-        private final ApplicationType type;
-        private final int size;
+    public void incrementServiceKey(ServiceType type, String attServiceKey, 
int size) {
+        getCollector().incrementServiceKey(getSource().getApplicationName(), 
getAttachmentValue(attServiceKey), type, size);
+    }
 
-        public MetricsDirectoryEvent(ApplicationModel applicationModel, 
ApplicationType type) {
-            this(applicationModel, type, 1);
-        }
+    public void addServiceKeyRT(String attServiceKey, String attSize) {
+        getCollector().addServiceKeyRT(getSource().getApplicationName(), 
getAttachmentValue(attServiceKey), attSize, getTimePair().calc());
+    }
 
-        public MetricsDirectoryEvent(ApplicationModel applicationModel, 
ApplicationType type, int size) {
-            super(applicationModel);
-            this.type = type;
-            this.size = size;
-        }
+    public void increment(ApplicationType type) {
+        getCollector().increment(getSource().getApplicationName(), type);
+    }
 
-        public ApplicationType getType() {
-            return type;
-        }
 
-        public int getSize() {
-            return size;
-        }
+    public static RegistryEvent toRegisterEvent(ApplicationModel 
applicationModel) {
+        return new RegistryEvent(applicationModel, new 
TypeWrapper(MetricsLevel.APP, ApplicationType.R_TOTAL, 
ApplicationType.R_SUCCEED, ApplicationType.R_FAILED));
     }
 
-    public static class MetricsServiceRegisterEvent extends RegistryEvent {
-
-        private final int size;
-        private final String serviceKey;
 
-        public MetricsServiceRegisterEvent(ApplicationModel applicationModel, 
String serviceKey, int size) {
-            super(applicationModel);
-            this.size = size;
-            this.serviceKey = serviceKey;
-        }
+    public static RegistryEvent toSubscribeEvent(ApplicationModel 
applicationModel) {
+        return new RegistryEvent(applicationModel, new 
TypeWrapper(MetricsLevel.APP, ApplicationType.S_TOTAL, 
ApplicationType.S_SUCCEED, ApplicationType.S_FAILED));
+    }
 
-        public int getSize() {
-            return size;
-        }
 
-        public String getServiceKey() {
-            return serviceKey;
-        }
+    public static RegistryEvent toNotifyEvent(ApplicationModel 
applicationModel) {
+        return new RegistryEvent(applicationModel, new 
TypeWrapper(MetricsLevel.APP, ApplicationType.N_TOTAL, ServiceType.N_LAST_NUM, 
null)) {
+            @Override
+            public void customAfterPost(Object postResult) {
+                super.attachment.put(ATTACHMENT_KEY_LAST_NUM_MAP, postResult);
+            }
+        };
     }
 
-    public static class MetricsServiceSubscribeEvent extends RegistryEvent {
+    public static RegistryEvent toRsEvent(ApplicationModel applicationModel, 
String serviceKey, int size) {
+        RegistryEvent ddEvent = new RegistryEvent(applicationModel, new 
TypeWrapper(MetricsLevel.SERVICE, ServiceType.R_SERVICE_TOTAL, 
ServiceType.R_SERVICE_SUCCEED, ServiceType.R_SERVICE_FAILED));
+        ddEvent.attachment.put(ATTACHMENT_KEY_SERVICE, serviceKey);
+        ddEvent.attachment.put(ATTACHMENT_KEY_SIZE, size);
+        return ddEvent;
+    }
 
-        private final String uniqueServiceName;
+    public static RegistryEvent toSsEvent(ApplicationModel applicationModel, 
String serviceKey) {
+        RegistryEvent ddEvent = new RegistryEvent(applicationModel, new 
TypeWrapper(MetricsLevel.SERVICE, ServiceType.S_SERVICE_TOTAL, 
ServiceType.S_SERVICE_SUCCEED, ServiceType.S_SERVICE_FAILED));
+        ddEvent.attachment.put(ATTACHMENT_KEY_SERVICE, serviceKey);
+        return ddEvent;
+    }
 
-        public MetricsServiceSubscribeEvent(ApplicationModel applicationModel, 
String uniqueServiceName) {
-            super(applicationModel);
-            this.uniqueServiceName = uniqueServiceName;
-        }
 
-        public String getUniqueServiceName() {
-            return uniqueServiceName;
-        }
-    }
 }
diff --git 
a/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/RegistryListener.java
 
b/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/RegistryListener.java
new file mode 100644
index 0000000000..beff249b1c
--- /dev/null
+++ 
b/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/RegistryListener.java
@@ -0,0 +1,67 @@
+/*
+ * 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.dubbo.metrics.registry.event;
+
+import org.apache.dubbo.metrics.event.MetricsEvent;
+import org.apache.dubbo.metrics.listener.MetricsLifeListener;
+
+import java.util.function.BiConsumer;
+
+public abstract class RegistryListener implements 
MetricsLifeListener<RegistryEvent> {
+
+    private final Object enumType;
+
+    public RegistryListener(Object enumType) {
+        this.enumType = enumType;
+    }
+
+    @Override
+    public boolean isSupport(MetricsEvent event) {
+        return event.isAvailable() && event.isAssignableFrom(enumType);
+    }
+
+    static <T> RegistryListener onEvent(T enumType, BiConsumer<RegistryEvent, 
T> postFunc) {
+
+        return new RegistryListener(enumType) {
+            @Override
+            public void onEvent(RegistryEvent event) {
+                postFunc.accept(event, enumType);
+            }
+        };
+    }
+
+    static <T> RegistryListener onFinish(T enumType, BiConsumer<RegistryEvent, 
T> finishFunc) {
+
+        return new RegistryListener(enumType) {
+            @Override
+            public void onEventFinish(RegistryEvent event) {
+                finishFunc.accept(event, enumType);
+            }
+        };
+    }
+
+    static <T> RegistryListener onError(T enumType, BiConsumer<RegistryEvent, 
T> errorFunc) {
+
+        return new RegistryListener(enumType) {
+            @Override
+            public void onEventError(RegistryEvent event) {
+                errorFunc.accept(event, enumType);
+            }
+        };
+    }
+}
diff --git 
a/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/RegistryMetricsEventMulticaster.java
 
b/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/RegistryMetricsEventMulticaster.java
index 3ad78a26c8..83590cde15 100644
--- 
a/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/RegistryMetricsEventMulticaster.java
+++ 
b/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/RegistryMetricsEventMulticaster.java
@@ -18,18 +18,108 @@
 package org.apache.dubbo.metrics.registry.event;
 
 import org.apache.dubbo.metrics.event.SimpleMetricsEventMulticaster;
+import org.apache.dubbo.metrics.registry.event.type.ApplicationType;
+import org.apache.dubbo.metrics.registry.event.type.ServiceType;
+
+import static 
org.apache.dubbo.metrics.registry.RegistryConstants.ATTACHMENT_KEY_DIR_NUM;
+import static 
org.apache.dubbo.metrics.registry.RegistryConstants.ATTACHMENT_KEY_SERVICE;
+import static 
org.apache.dubbo.metrics.registry.RegistryConstants.OP_TYPE_NOTIFY;
+import static 
org.apache.dubbo.metrics.registry.RegistryConstants.OP_TYPE_REGISTER;
+import static 
org.apache.dubbo.metrics.registry.RegistryConstants.OP_TYPE_REGISTER_SERVICE;
+import static 
org.apache.dubbo.metrics.registry.RegistryConstants.OP_TYPE_SUBSCRIBE;
+import static 
org.apache.dubbo.metrics.registry.RegistryConstants.OP_TYPE_SUBSCRIBE_SERVICE;
 
 public final class RegistryMetricsEventMulticaster extends 
SimpleMetricsEventMulticaster {
 
     public RegistryMetricsEventMulticaster() {
-        super.addListener(new MetricsRegisterListener());
-        super.addListener(new MetricsSubscribeListener());
-        super.addListener(new MetricsNotifyListener());
-        super.addListener(new MetricsDirectoryListener());
-        super.addListener(new MetricsServiceRegisterListener());
-        super.addListener(new MetricsServiceSubscribeListener());
+        // MetricsRegisterListener
+        super.addListener(onPostEventBuild(ApplicationType.R_TOTAL));
+        super.addListener(onFinishEventBuild(ApplicationType.R_SUCCEED, 
OP_TYPE_REGISTER));
+        super.addListener(onErrorEventBuild(ApplicationType.R_FAILED, 
OP_TYPE_REGISTER));
+
+        // MetricsSubscribeListener
+        super.addListener(onPostEventBuild(ApplicationType.S_TOTAL));
+        super.addListener(onFinishEventBuild(ApplicationType.S_SUCCEED, 
OP_TYPE_SUBSCRIBE));
+        super.addListener(onErrorEventBuild(ApplicationType.S_FAILED, 
OP_TYPE_SUBSCRIBE));
+
+        // MetricsNotifyListener
+        super.addListener(onPostEventBuild(ApplicationType.N_TOTAL));
+        super.addListener(
+            RegistryListener.onFinish(ServiceType.N_LAST_NUM,
+                (event, type) -> {
+                    event.setLastNum(type);
+                    event.addApplicationRT(OP_TYPE_NOTIFY);
+                }
+            ));
+
+
+        // MetricsDirectoryListener
+        addIncrListener(ApplicationType.D_VALID);
+        addIncrListener(ApplicationType.D_UN_VALID);
+        addIncrListener(ApplicationType.D_DISABLE);
+        addIncrListener(ApplicationType.D_RECOVER_DISABLE);
+        super.addListener(RegistryListener.onEvent(ApplicationType.D_CURRENT,
+            (event, type) -> event.setNum(type, ATTACHMENT_KEY_DIR_NUM))
+        );
+
+        // MetricsServiceRegisterListener
+        super.addListener(RegistryListener.onEvent(ServiceType.R_SERVICE_TOTAL,
+            this::incrSkSize
+        ));
+        
super.addListener(RegistryListener.onFinish(ServiceType.R_SERVICE_SUCCEED, 
this::onRegisterRtEvent));
+        
super.addListener(RegistryListener.onError(ServiceType.R_SERVICE_FAILED, 
this::onRegisterRtEvent));
 
-        setAvailable();
+        // MetricsServiceSubscribeListener
+        
super.addListener(RegistryListener.onEvent(ServiceType.S_SERVICE_TOTAL, 
this::incrSk));
+        
super.addListener(RegistryListener.onFinish(ServiceType.S_SERVICE_SUCCEED, 
this::onRtEvent));
+        
super.addListener(RegistryListener.onError(ServiceType.S_SERVICE_FAILED, 
this::onRtEvent));
     }
 
+
+    private void addIncrListener(ApplicationType applicationType) {
+        super.addListener(onPostEventBuild(applicationType));
+    }
+
+    private RegistryListener onPostEventBuild(ApplicationType applicationType) 
{
+        return RegistryListener.onEvent(applicationType,
+            (event, type) -> 
event.getCollector().increment(event.getSource().getApplicationName(), type)
+        );
+    }
+
+    private RegistryListener onFinishEventBuild(ApplicationType 
applicationType, String registryOpType) {
+        return RegistryListener.onFinish(applicationType,
+            (event, type) -> {
+                event.increment(type);
+                event.addApplicationRT(registryOpType);
+            }
+        );
+    }
+
+    private RegistryListener onErrorEventBuild(ApplicationType 
applicationType, String registryOpType) {
+        return RegistryListener.onError(applicationType,
+            (event, type) -> {
+                event.increment(type);
+                event.addApplicationRT(registryOpType);
+            }
+        );
+    }
+
+
+    private void incrSk(RegistryEvent event, ServiceType type) {
+        event.incrementServiceKey(type, ATTACHMENT_KEY_SERVICE, 1);
+    }
+
+    private void incrSkSize(RegistryEvent event, ServiceType type) {
+        event.incrementServiceKey(type, ATTACHMENT_KEY_SERVICE, 
org.apache.dubbo.metrics.registry.RegistryConstants.ATTACHMENT_KEY_SIZE);
+    }
+
+    private void onRtEvent(RegistryEvent event, ServiceType type) {
+        incrSk(event, type);
+        event.addServiceKeyRT(ATTACHMENT_KEY_SERVICE, 
OP_TYPE_SUBSCRIBE_SERVICE);
+    }
+
+    private void onRegisterRtEvent(RegistryEvent event, ServiceType type) {
+        incrSkSize(event, type);
+        event.addServiceKeyRT(ATTACHMENT_KEY_SERVICE, 
OP_TYPE_REGISTER_SERVICE);
+    }
 }
diff --git 
a/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/support/DirectorSupport.java
 
b/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/support/DirectorSupport.java
new file mode 100644
index 0000000000..cf5dabdb22
--- /dev/null
+++ 
b/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/support/DirectorSupport.java
@@ -0,0 +1,51 @@
+/*
+ * 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.dubbo.metrics.registry.event.support;
+
+import org.apache.dubbo.metrics.model.MetricsLevel;
+import org.apache.dubbo.metrics.model.TypeWrapper;
+import org.apache.dubbo.metrics.registry.event.RegistryEvent;
+import org.apache.dubbo.metrics.registry.event.type.ApplicationType;
+import org.apache.dubbo.rpc.model.ApplicationModel;
+
+import static 
org.apache.dubbo.metrics.registry.RegistryConstants.ATTACHMENT_KEY_DIR_NUM;
+
+public class DirectorSupport {
+
+    public static RegistryEvent disable(ApplicationModel applicationModel) {
+        return new RegistryEvent(applicationModel, new 
TypeWrapper(MetricsLevel.APP, ApplicationType.D_DISABLE, null, null));
+    }
+
+    public static RegistryEvent valid(ApplicationModel applicationModel) {
+        return new RegistryEvent(applicationModel, new 
TypeWrapper(MetricsLevel.APP, ApplicationType.D_VALID, null, null));
+    }
+
+    public static RegistryEvent unValid(ApplicationModel applicationModel) {
+        return new RegistryEvent(applicationModel, new 
TypeWrapper(MetricsLevel.APP, ApplicationType.D_UN_VALID, null, null));
+    }
+
+    public static RegistryEvent current(ApplicationModel applicationModel, int 
num) {
+        RegistryEvent ddEvent = new RegistryEvent(applicationModel, new 
TypeWrapper(MetricsLevel.APP, ApplicationType.D_CURRENT, null, null));
+        ddEvent.putAttachment(ATTACHMENT_KEY_DIR_NUM, num);
+        return ddEvent;
+    }
+
+    public static RegistryEvent recover(ApplicationModel applicationModel) {
+        return new RegistryEvent(applicationModel, new 
TypeWrapper(MetricsLevel.APP, ApplicationType.D_RECOVER_DISABLE, null, null));
+    }
+}
diff --git 
a/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/type/ApplicationType.java
 
b/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/type/ApplicationType.java
new file mode 100644
index 0000000000..75ed1183f7
--- /dev/null
+++ 
b/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/type/ApplicationType.java
@@ -0,0 +1,51 @@
+/*
+ * 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.dubbo.metrics.registry.event.type;
+
+import org.apache.dubbo.metrics.model.MetricsKey;
+
+public enum ApplicationType {
+    R_TOTAL(MetricsKey.REGISTER_METRIC_REQUESTS),
+    R_SUCCEED(MetricsKey.REGISTER_METRIC_REQUESTS_SUCCEED),
+    R_FAILED(MetricsKey.REGISTER_METRIC_REQUESTS_FAILED),
+
+    S_TOTAL(MetricsKey.SUBSCRIBE_METRIC_NUM),
+    S_SUCCEED(MetricsKey.SUBSCRIBE_METRIC_NUM_SUCCEED),
+    S_FAILED(MetricsKey.SUBSCRIBE_METRIC_NUM_FAILED),
+
+    D_VALID(MetricsKey.DIRECTORY_METRIC_NUM_VALID),
+    D_UN_VALID(MetricsKey.DIRECTORY_METRIC_NUM_UN_VALID),
+    D_DISABLE(MetricsKey.DIRECTORY_METRIC_NUM_DISABLE),
+    D_CURRENT(MetricsKey.DIRECTORY_METRIC_NUM_CURRENT),
+    D_RECOVER_DISABLE(MetricsKey.DIRECTORY_METRIC_NUM_RECOVER_DISABLE),
+
+    N_TOTAL(MetricsKey.NOTIFY_METRIC_REQUESTS),
+    ;
+
+    private final MetricsKey metricsKey;
+
+
+    ApplicationType(MetricsKey metricsKey) {
+        this.metricsKey = metricsKey;
+    }
+
+    public MetricsKey getMetricsKey() {
+        return metricsKey;
+    }
+
+}
diff --git 
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/MethodEvent.java
 
b/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/type/ServiceType.java
similarity index 50%
copy from 
dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/MethodEvent.java
copy to 
dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/type/ServiceType.java
index 59429bf605..612ce497a0 100644
--- 
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/MethodEvent.java
+++ 
b/dubbo-metrics/dubbo-metrics-registry/src/main/java/org/apache/dubbo/metrics/registry/event/type/ServiceType.java
@@ -15,32 +15,31 @@
  * limitations under the License.
  */
 
-package org.apache.dubbo.metrics.event;
+package org.apache.dubbo.metrics.registry.event.type;
 
-import org.apache.dubbo.metrics.model.MethodMetric;
-import org.apache.dubbo.rpc.model.ApplicationModel;
+import org.apache.dubbo.metrics.model.MetricsKey;
 
-public class MethodEvent extends MetricsEvent {
-    private String type;
-    private final MethodMetric methodMetric;
+public enum ServiceType {
 
-    public MethodEvent(ApplicationModel applicationModel, MethodMetric 
methodMetric, String type) {
-        super(applicationModel);
-        this.type = type;
-        this.methodMetric = methodMetric;
-    }
+    N_LAST_NUM(MetricsKey.NOTIFY_METRIC_NUM_LAST),
 
-    public MethodMetric getMethodMetric() {
-        return methodMetric;
-    }
+    R_SERVICE_TOTAL(MetricsKey.SERVICE_REGISTER_METRIC_REQUESTS),
+    R_SERVICE_SUCCEED(MetricsKey.SERVICE_REGISTER_METRIC_REQUESTS_SUCCEED),
+    R_SERVICE_FAILED(MetricsKey.SERVICE_REGISTER_METRIC_REQUESTS_FAILED),
 
-    public String getType() {
-        return type;
-    }
+    S_SERVICE_TOTAL(MetricsKey.SERVICE_SUBSCRIBE_METRIC_NUM),
+    S_SERVICE_SUCCEED(MetricsKey.SERVICE_SUBSCRIBE_METRIC_NUM_SUCCEED),
+    S_SERVICE_FAILED(MetricsKey.SERVICE_SUBSCRIBE_METRIC_NUM_FAILED),
+    ;
 
-    public void setType(String type) {
-        this.type = type;
+    private final MetricsKey metricsKey;
+
+    ServiceType(MetricsKey metricsKey) {
+        this.metricsKey = metricsKey;
     }
 
+    public MetricsKey getMetricsKey() {
+        return metricsKey;
+    }
 
 }
diff --git 
a/dubbo-metrics/dubbo-metrics-registry/src/test/java/org/apache/dubbo/metrics/registry/metrics/collector/RegistryMetricsCollectorTest.java
 
b/dubbo-metrics/dubbo-metrics-registry/src/test/java/org/apache/dubbo/metrics/registry/metrics/collector/RegistryMetricsCollectorTest.java
index e94f1ba594..2f90dbc1ea 100644
--- 
a/dubbo-metrics/dubbo-metrics-registry/src/test/java/org/apache/dubbo/metrics/registry/metrics/collector/RegistryMetricsCollectorTest.java
+++ 
b/dubbo-metrics/dubbo-metrics-registry/src/test/java/org/apache/dubbo/metrics/registry/metrics/collector/RegistryMetricsCollectorTest.java
@@ -40,9 +40,9 @@ import java.util.Objects;
 import java.util.stream.Collectors;
 
 import static 
org.apache.dubbo.common.constants.MetricsConstants.TAG_APPLICATION_NAME;
-import static 
org.apache.dubbo.metrics.registry.collector.stat.RegistryStatComposite.OP_TYPE_REGISTER;
-import static 
org.apache.dubbo.metrics.registry.collector.stat.RegistryStatComposite.OP_TYPE_REGISTER_SERVICE;
-import static 
org.apache.dubbo.metrics.registry.collector.stat.RegistryStatComposite.OP_TYPE_SUBSCRIBE_SERVICE;
+import static 
org.apache.dubbo.metrics.registry.RegistryConstants.OP_TYPE_REGISTER;
+import static 
org.apache.dubbo.metrics.registry.RegistryConstants.OP_TYPE_REGISTER_SERVICE;
+import static 
org.apache.dubbo.metrics.registry.RegistryConstants.OP_TYPE_SUBSCRIBE_SERVICE;
 
 
 class RegistryMetricsCollectorTest {
@@ -72,7 +72,7 @@ class RegistryMetricsCollectorTest {
         RegistryMetricsCollector collector = 
applicationModel.getBeanFactory().getOrRegisterBean(RegistryMetricsCollector.class);
         collector.setCollectEnabled(true);
 
-        RegistryEvent registryEvent = new 
RegistryEvent.MetricsApplicationRegisterEvent(applicationModel);
+        RegistryEvent registryEvent = 
RegistryEvent.toRegisterEvent(applicationModel);
         MetricsEventBus.post(registryEvent,
             () -> {
                 List<MetricSample> metricSamples = collector.collect();
@@ -90,7 +90,7 @@ class RegistryMetricsCollectorTest {
         long c1 = registryEvent.getTimePair().calc();
 
 
-        registryEvent = new 
RegistryEvent.MetricsApplicationRegisterEvent(applicationModel);
+        registryEvent = RegistryEvent.toRegisterEvent(applicationModel);
         TimePair lastTimePair = registryEvent.getTimePair();
         MetricsEventBus.post(registryEvent,
             () -> {
@@ -135,7 +135,7 @@ class RegistryMetricsCollectorTest {
         collector.setCollectEnabled(true);
         String serviceName = "demo.gameService";
 
-        RegistryEvent registryEvent = new 
RegistryEvent.MetricsServiceRegisterEvent(applicationModel, serviceName,2);
+        RegistryEvent registryEvent = 
RegistryEvent.toRsEvent(applicationModel, serviceName, 2);
         MetricsEventBus.post(registryEvent,
             () -> {
                 List<MetricSample> metricSamples = collector.collect();
@@ -155,7 +155,7 @@ class RegistryMetricsCollectorTest {
         Assertions.assertEquals(7, metricSamples.size());
 
         long c1 = registryEvent.getTimePair().calc();
-        registryEvent = new 
RegistryEvent.MetricsServiceRegisterEvent(applicationModel, serviceName,2);
+        registryEvent = RegistryEvent.toRsEvent(applicationModel, serviceName, 
2);
         TimePair lastTimePair = registryEvent.getTimePair();
         MetricsEventBus.post(registryEvent,
             () -> {
@@ -200,7 +200,7 @@ class RegistryMetricsCollectorTest {
         collector.setCollectEnabled(true);
         String serviceName = "demo.gameService";
 
-        RegistryEvent subscribeEvent = new 
RegistryEvent.MetricsServiceSubscribeEvent(applicationModel, serviceName);
+        RegistryEvent subscribeEvent = 
RegistryEvent.toSsEvent(applicationModel, serviceName);
         MetricsEventBus.post(subscribeEvent,
             () -> {
                 List<MetricSample> metricSamples = collector.collect();
@@ -220,7 +220,7 @@ class RegistryMetricsCollectorTest {
         Assertions.assertEquals(7, metricSamples.size());
 
         long c1 = subscribeEvent.getTimePair().calc();
-        subscribeEvent = new 
RegistryEvent.MetricsServiceSubscribeEvent(applicationModel, serviceName);
+        subscribeEvent = RegistryEvent.toSsEvent(applicationModel, 
serviceName);
         TimePair lastTimePair = subscribeEvent.getTimePair();
         MetricsEventBus.post(subscribeEvent,
             () -> {
diff --git 
a/dubbo-metrics/dubbo-metrics-registry/src/test/java/org/apache/dubbo/metrics/registry/metrics/collector/RegistryMetricsSampleTest.java
 
b/dubbo-metrics/dubbo-metrics-registry/src/test/java/org/apache/dubbo/metrics/registry/metrics/collector/RegistryMetricsSampleTest.java
index 27b7a4f736..c797f70151 100644
--- 
a/dubbo-metrics/dubbo-metrics-registry/src/test/java/org/apache/dubbo/metrics/registry/metrics/collector/RegistryMetricsSampleTest.java
+++ 
b/dubbo-metrics/dubbo-metrics-registry/src/test/java/org/apache/dubbo/metrics/registry/metrics/collector/RegistryMetricsSampleTest.java
@@ -23,8 +23,7 @@ import org.apache.dubbo.metrics.model.MetricsKeyWrapper;
 import org.apache.dubbo.metrics.model.sample.GaugeMetricSample;
 import org.apache.dubbo.metrics.model.sample.MetricSample;
 import org.apache.dubbo.metrics.registry.collector.RegistryMetricsCollector;
-import org.apache.dubbo.metrics.registry.collector.stat.RegistryStatComposite;
-import org.apache.dubbo.metrics.registry.event.RegistryEvent;
+import org.apache.dubbo.metrics.registry.event.type.ApplicationType;
 import org.apache.dubbo.rpc.model.ApplicationModel;
 import org.apache.dubbo.rpc.model.FrameworkModel;
 import org.junit.jupiter.api.AfterEach;
@@ -37,6 +36,7 @@ import java.util.Map;
 import java.util.stream.Collectors;
 
 import static 
org.apache.dubbo.common.constants.MetricsConstants.TAG_APPLICATION_NAME;
+import static 
org.apache.dubbo.metrics.registry.RegistryConstants.OP_TYPE_REGISTER;
 
 class RegistryMetricsSampleTest {
 
@@ -65,8 +65,8 @@ class RegistryMetricsSampleTest {
         RegistryMetricsCollector collector = new 
RegistryMetricsCollector(applicationModel);
         collector.setCollectEnabled(true);
         String applicationName = applicationModel.getApplicationName();
-        collector.addApplicationRT(applicationName, 
RegistryStatComposite.OP_TYPE_REGISTER, 10L);
-        collector.addApplicationRT(applicationName, 
RegistryStatComposite.OP_TYPE_REGISTER, 0L);
+        collector.addApplicationRT(applicationName, OP_TYPE_REGISTER, 10L);
+        collector.addApplicationRT(applicationName, OP_TYPE_REGISTER, 0L);
 
         List<MetricSample> samples = collector.collect();
         for (MetricSample sample : samples) {
@@ -77,11 +77,11 @@ class RegistryMetricsSampleTest {
         @SuppressWarnings("rawtypes")
         Map<String, Long> sampleMap = 
samples.stream().collect(Collectors.toMap(MetricSample::getName, k -> 
((GaugeMetricSample) k).applyAsLong()));
 
-        Assertions.assertEquals(sampleMap.get(new 
MetricsKeyWrapper(RegistryStatComposite.OP_TYPE_REGISTER, 
MetricsKey.METRIC_RT_LAST).targetKey()), 0L);
-        Assertions.assertEquals(sampleMap.get(new 
MetricsKeyWrapper(RegistryStatComposite.OP_TYPE_REGISTER, 
MetricsKey.METRIC_RT_MIN).targetKey()), 0L);
-        Assertions.assertEquals(sampleMap.get(new 
MetricsKeyWrapper(RegistryStatComposite.OP_TYPE_REGISTER, 
MetricsKey.METRIC_RT_MAX).targetKey()), 10L);
-        Assertions.assertEquals(sampleMap.get(new 
MetricsKeyWrapper(RegistryStatComposite.OP_TYPE_REGISTER, 
MetricsKey.METRIC_RT_AVG).targetKey()), 5L);
-        Assertions.assertEquals(sampleMap.get(new 
MetricsKeyWrapper(RegistryStatComposite.OP_TYPE_REGISTER, 
MetricsKey.METRIC_RT_SUM).targetKey()), 10L);
+        Assertions.assertEquals(sampleMap.get(new 
MetricsKeyWrapper(OP_TYPE_REGISTER, MetricsKey.METRIC_RT_LAST).targetKey()), 
0L);
+        Assertions.assertEquals(sampleMap.get(new 
MetricsKeyWrapper(OP_TYPE_REGISTER, MetricsKey.METRIC_RT_MIN).targetKey()), 0L);
+        Assertions.assertEquals(sampleMap.get(new 
MetricsKeyWrapper(OP_TYPE_REGISTER, MetricsKey.METRIC_RT_MAX).targetKey()), 
10L);
+        Assertions.assertEquals(sampleMap.get(new 
MetricsKeyWrapper(OP_TYPE_REGISTER, MetricsKey.METRIC_RT_AVG).targetKey()), 5L);
+        Assertions.assertEquals(sampleMap.get(new 
MetricsKeyWrapper(OP_TYPE_REGISTER, MetricsKey.METRIC_RT_SUM).targetKey()), 
10L);
     }
 
     @Test
@@ -89,7 +89,7 @@ class RegistryMetricsSampleTest {
         RegistryMetricsCollector collector = new 
RegistryMetricsCollector(applicationModel);
         collector.setCollectEnabled(true);
         String applicationName = applicationModel.getApplicationName();
-        collector.increment(applicationName, 
RegistryEvent.ApplicationType.R_TOTAL);
+        collector.increment(applicationName, ApplicationType.R_TOTAL);
     }
 
 }
diff --git 
a/dubbo-metrics/dubbo-metrics-registry/src/test/java/org/apache/dubbo/metrics/registry/metrics/collector/RegistryStatCompositeTest.java
 
b/dubbo-metrics/dubbo-metrics-registry/src/test/java/org/apache/dubbo/metrics/registry/metrics/collector/RegistryStatCompositeTest.java
index 036f8ae4e5..6cc653a818 100644
--- 
a/dubbo-metrics/dubbo-metrics-registry/src/test/java/org/apache/dubbo/metrics/registry/metrics/collector/RegistryStatCompositeTest.java
+++ 
b/dubbo-metrics/dubbo-metrics-registry/src/test/java/org/apache/dubbo/metrics/registry/metrics/collector/RegistryStatCompositeTest.java
@@ -19,7 +19,7 @@ package org.apache.dubbo.metrics.registry.metrics.collector;
 
 import org.apache.dubbo.metrics.model.container.LongContainer;
 import org.apache.dubbo.metrics.registry.collector.stat.RegistryStatComposite;
-import org.apache.dubbo.metrics.registry.event.RegistryEvent;
+import org.apache.dubbo.metrics.registry.event.type.ApplicationType;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
@@ -27,7 +27,7 @@ import java.util.Map;
 import java.util.Optional;
 import java.util.concurrent.ConcurrentHashMap;
 
-import static 
org.apache.dubbo.metrics.registry.collector.stat.RegistryStatComposite.OP_TYPE_NOTIFY;
+import static 
org.apache.dubbo.metrics.registry.RegistryConstants.OP_TYPE_NOTIFY;
 
 public class RegistryStatCompositeTest {
 
@@ -36,7 +36,7 @@ public class RegistryStatCompositeTest {
     @Test
     void testInit() {
         RegistryStatComposite statComposite = new RegistryStatComposite();
-        Assertions.assertEquals(statComposite.applicationNumStats.size(), 
RegistryEvent.ApplicationType.values().length);
+        Assertions.assertEquals(statComposite.applicationNumStats.size(), 
ApplicationType.values().length);
         //(rt)5 * 
(register,subscribe,notify,register.service,subscribe.service)5
         Assertions.assertEquals(5 * 5, statComposite.rtStats.size());
         statComposite.applicationNumStats.values().forEach((v ->
@@ -52,8 +52,8 @@ public class RegistryStatCompositeTest {
     @Test
     void testIncrement() {
         RegistryStatComposite statComposite = new RegistryStatComposite();
-        statComposite.increment(RegistryEvent.ApplicationType.R_TOTAL, 
applicationName);
-        Assertions.assertEquals(1L, 
statComposite.applicationNumStats.get(RegistryEvent.ApplicationType.R_TOTAL).get(applicationName).get());
+        statComposite.increment(ApplicationType.R_TOTAL, applicationName);
+        Assertions.assertEquals(1L, 
statComposite.applicationNumStats.get(ApplicationType.R_TOTAL).get(applicationName).get());
     }
 
     @Test
diff --git 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistry.java
 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistry.java
index e689b2ecc8..003892c6ca 100644
--- 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistry.java
+++ 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistry.java
@@ -328,7 +328,8 @@ public class ServiceDiscoveryRegistry extends 
FailbackRegistry {
                 listener.addServiceListener(serviceInstancesChangedListener);
                 serviceInstancesChangedListener.addListenerAndNotify(url, 
listener);
                 ServiceInstancesChangedListener 
finalServiceInstancesChangedListener = serviceInstancesChangedListener;
-                MetricsEventBus.post(new 
RegistryEvent.MetricsServiceSubscribeEvent(url.getApplicationModel(), 
serviceKey),
+
+                
MetricsEventBus.post(RegistryEvent.toSsEvent(url.getApplicationModel(), 
serviceKey),
                     () -> {
                         
serviceDiscovery.addServiceInstancesChangedListener(finalServiceInstancesChangedListener);
                         return null;
diff --git 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/event/listener/ServiceInstancesChangedListener.java
 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/event/listener/ServiceInstancesChangedListener.java
index 655e72fc19..e069ead88c 100644
--- 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/event/listener/ServiceInstancesChangedListener.java
+++ 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/event/listener/ServiceInstancesChangedListener.java
@@ -65,6 +65,8 @@ import static 
org.apache.dubbo.common.constants.RegistryConstants.ENABLE_EMPTY_P
 import static org.apache.dubbo.metadata.RevisionResolver.EMPTY_REVISION;
 import static 
org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.getExportedServicesRevision;
 
+;
+
 /**
  * TODO, refactor to move revision-metadata mapping to ServiceDiscovery. 
Instances should have already been mapped with metadata when reached here.
  * <p>
@@ -403,7 +405,7 @@ public class ServiceInstancesChangedListener {
      */
     protected void notifyAddressChanged() {
 
-        MetricsEventBus.post(new 
RegistryEvent.MetricsNotifyEvent(applicationModel),
+        MetricsEventBus.post(RegistryEvent.toNotifyEvent(applicationModel),
             () -> {
                 Map<String, Integer> lastNumMap = new HashMap<>();
                 // 1 different services
diff --git 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java
 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java
index 53e6bd3706..0fbdcc036e 100644
--- 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java
+++ 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java
@@ -119,7 +119,7 @@ public class RegistryDirectory<T> extends 
DynamicDirectory<T> {
     @Override
     public void subscribe(URL url) {
         ApplicationModel applicationModel = url.getApplicationModel();
-        MetricsEventBus.post(new 
RegistryEvent.MetricsSubscribeEvent(applicationModel),() ->
+        
MetricsEventBus.post(RegistryEvent.toSubscribeEvent(applicationModel),() ->
             {
                 super.subscribe(url);
                 return null;


Reply via email to