Skip to content

Commit

Permalink
1. dubbo monitor parameters add group and version (apache#1407)
Browse files Browse the repository at this point in the history
2. monitor interval can be override by outside setting
  • Loading branch information
YoungHu authored and beiwei30 committed Apr 10, 2018
1 parent 38f45ee commit 2e84f07
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public class MonitorConfig extends AbstractConfig {

private String version;

private String interval;

// customized parameters
private Map<String, String> parameters;

Expand Down Expand Up @@ -123,4 +125,12 @@ public void setDefault(Boolean isDefault) {
this.isDefault = isDefault;
}

public void setInterval(String interval){
this.interval = interval;
}

public String getInterval(){
return interval;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,11 @@
<xsd:documentation><![CDATA[ The monitor version. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="interval" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ The monitor interval. ]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="default" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation><![CDATA[ Is default. ]]></xsd:documentation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ private void collect(Invoker<?> invoker, Invocation invocation, Result result, S
String application = invoker.getUrl().getParameter(Constants.APPLICATION_KEY);
String service = invoker.getInterface().getName(); // service name
String method = RpcUtils.getMethodName(invocation); // method name
String group = invoker.getUrl().getParameter(Constants.GROUP_KEY);
String version = invoker.getUrl().getParameter(Constants.VERSION_KEY);
URL url = invoker.getUrl().getUrlParameter(Constants.MONITOR_KEY);
Monitor monitor = monitorFactory.getMonitor(url);
if (monitor == null) {
Expand Down Expand Up @@ -121,7 +123,9 @@ private void collect(Invoker<?> invoker, Invocation invocation, Result result, S
MonitorService.ELAPSED, String.valueOf(elapsed),
MonitorService.CONCURRENT, String.valueOf(concurrent),
Constants.INPUT_KEY, input,
Constants.OUTPUT_KEY, output));
Constants.OUTPUT_KEY, output,
Constants.GROUP_KEY, group,
Constants.VERSION_KEY, version));
} catch (Throwable t) {
logger.error("Failed to monitor count service " + invoker.getUrl() + ", cause: " + t.getMessage(), t);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package com.alibaba.dubbo.monitor.dubbo;

import com.alibaba.dubbo.common.Constants;
import com.alibaba.dubbo.common.URL;
import com.alibaba.dubbo.common.logger.Logger;
import com.alibaba.dubbo.common.logger.LoggerFactory;
Expand Down Expand Up @@ -92,6 +93,7 @@ public void send() {
long maxOutput = numbers[7];
long maxElapsed = numbers[8];
long maxConcurrent = numbers[9];
String version = getUrl().getParameter(Constants.DEFAULT_PROTOCOL);

// send statistics data
URL url = statistics.getUrl()
Expand All @@ -105,7 +107,8 @@ public void send() {
MonitorService.MAX_INPUT, String.valueOf(maxInput),
MonitorService.MAX_OUTPUT, String.valueOf(maxOutput),
MonitorService.MAX_ELAPSED, String.valueOf(maxElapsed),
MonitorService.MAX_CONCURRENT, String.valueOf(maxConcurrent)
MonitorService.MAX_CONCURRENT, String.valueOf(maxConcurrent),
Constants.DEFAULT_PROTOCOL, version
);
monitorService.collect(url);

Expand Down

0 comments on commit 2e84f07

Please sign in to comment.