Dubbo-monitor简单介绍
2018-02-01 本文已影响0人
DogF
O、dubbo-monitor介绍
用来统计服务的调⽤次数和调⽤时间的监控中⼼。

一、使用方法
1.下载源码:github地址:https://github.com/dubbo/dubbo-ops
2.编译打包项目,拿到assembly包。解压后做相应配置(zk地址/端口号..),bin目录下启动服务。浏览器查看相应图形界面。

3.dubbo项目配置xml,一般配置protocol=registry,然后会自动读取dubbo-monitor服务,进行打点。

二、代码解释
1.匹配
如果项目中的dubbo配置有增加dubbo:monitor标签,在dubbo的MonitorFilter中会检测该标签,如果有的话,就会调用monitor服务进行统计。

2.获取monitor
从dubbo注册中心中找出实现了MonitorService的服务,在“使用方法” 第二步启动monitor服务后,会使用暴露MonitorService服务。
然后通过Monitor封装MonitorService对象返回。

3.本地收集
内存中维护了一个ConcurrentMap,来统计本地每个服务的调用信息(成功、失败、出入参、耗时、当前并发量等)

4.远程收集
Monitor接口的实现DubboMonitor在初始化时,启动了一个定时任务,定时将本地收集的服务调用信息发往远程服务。使用ScheduledExecutorService.scheduleWithFixedDelay();
任务周期:启动服务1分钟后发送,下一次在上一次发送完成后+1分钟发送。
