监控中心扩展

监控中心扩展

扩展说明

负责服务调用次和调用时间的监控。

扩展接口

  • org.apache.dubbo.monitor.MonitorFactory
  • org.apache.dubbo.monitor.Monitor

扩展配置

  1. <!-- 定义监控中心 -->
  2. <dubbo:monitor address="xxx://ip:port" />

已知扩展

org.apache.dubbo.monitor.support.dubbo.DubboMonitorFactory

扩展示例

Maven 项目结构:

  1. src
  2. |-main
  3. |-java
  4. |-com
  5. |-xxx
  6. |-XxxMonitorFactoryjava (实现MonitorFactory接口)
  7. |-XxxMonitor.java (实现Monitor接口)
  8. |-resources
  9. |-META-INF
  10. |-dubbo
  11. |-org.apache.dubbo.monitor.MonitorFactory (纯文本文件,内容为:xxx=com.xxx.XxxMonitorFactory)

XxxMonitorFactory.java:

  1. package com.xxx;
  2. import org.apache.dubbo.monitor.MonitorFactory;
  3. import org.apache.dubbo.monitor.Monitor;
  4. import org.apache.dubbo.common.URL;
  5. public class XxxMonitorFactory implements MonitorFactory {
  6. public Monitor getMonitor(URL url) {
  7. return new XxxMonitor(url);
  8. }
  9. }

XxxMonitor.java:

  1. package com.xxx;
  2. import org.apache.dubbo.monitor.Monitor;
  3. public class XxxMonitor implements Monitor {
  4. public void count(URL statistics) {
  5. // ...
  6. }
  7. }

META-INF/dubbo/org.apache.dubbo.monitor.MonitorFactory:

  1. xxx=com.xxx.XxxMonitorFactory

最后修改 March 2, 2023: Fix alias forward in docs3-v2 (#2342) (f16c1535592)