WillemJiang commented on a change in pull request #555: [SCB-327] Update
metrics publish data module (Re-organized)
URL:
https://github.com/apache/incubator-servicecomb-java-chassis/pull/555#discussion_r169885809
##########
File path:
demo/perf/src/main/java/org/apache/servicecomb/demo/perf/PerfMetricsFilePublisher.java
##########
@@ -75,54 +76,56 @@ private void collectVertxMetrics(MetricsLoader loader,
StringBuilder sb) {
}
private void collectMetrics(MetricsLoader loader, StringBuilder sb) {
- MetricNode treeNode = loader
- .getMetricTree(MetricsConst.SERVICECOMB_INVOCATION,
MetricsConst.TAG_ROLE, MetricsConst.TAG_OPERATION,
- MetricsConst.TAG_STATUS);
-
- if (treeNode != null && treeNode.getChildren().size() != 0) {
- MetricNode consumerNode =
treeNode.getChildren().get(MetricsConst.ROLE_CONSUMER);
- if (consumerNode != null) {
- sb.append("consumer:\n");
- sb.append(" tps latency(ms) status operation\n");
- for (Entry<String, MetricNode> operationNode :
consumerNode.getChildren().entrySet()) {
- for (Entry<String, MetricNode> statusNode :
operationNode.getValue().getChildren().entrySet()) {
- sb.append(String.format(" %-7.0f %-11.3f %-9s %s\n",
- statusNode.getValue()
-
.getFirstMatchMetricValue(Lists.newArrayList(MetricsConst.TAG_STAGE,
MetricsConst.TAG_STATISTIC),
- Lists.newArrayList(MetricsConst.STAGE_WHOLE, "tps")),
- statusNode.getValue()
-
.getFirstMatchMetricValue(Lists.newArrayList(MetricsConst.TAG_STAGE,
MetricsConst.TAG_STATISTIC),
- Lists.newArrayList(MetricsConst.STAGE_WHOLE,
"latency")),
- statusNode.getKey(),
- operationNode.getKey()));
+ try {
+ MetricNode treeNode = loader
+ .getMetricTree(MetricsConst.SERVICECOMB_INVOCATION,
MetricsConst.TAG_ROLE, MetricsConst.TAG_OPERATION,
+ MetricsConst.TAG_STATUS);
+
+ if (treeNode != null && treeNode.getChildren().size() != 0) {
+ MetricNode consumerNode =
treeNode.getChildren().get(String.valueOf(InvocationType.CONSUMER));
+ if (consumerNode != null) {
+ sb.append("consumer:\n");
+ sb.append(" tps latency(ms) status operation\n");
+ for (Entry<String, MetricNode> operationNode :
consumerNode.getChildren().entrySet()) {
+ for (Entry<String, MetricNode> statusNode :
operationNode.getValue().getChildren().entrySet()) {
+ sb.append(String.format(" %-7.0f %-11.3f %-9s %s\n",
+ statusNode.getValue()
+ .getFirstMatchMetricValue(MetricsConst.TAG_STAGE,
MetricsConst.STAGE_TOTAL,
+ MetricsConst.TAG_STATISTIC, "tps"),
+ statusNode.getValue()
+ .getFirstMatchMetricValue(TimeUnit.MILLISECONDS,
MetricsConst.TAG_STAGE, MetricsConst.STAGE_TOTAL,
+ MetricsConst.TAG_STATISTIC, "latency"),
+ statusNode.getKey(), operationNode.getKey()));
+ }
}
}
- }
- MetricNode producerNode =
treeNode.getChildren().get(MetricsConst.ROLE_PRODUCER);
- if (producerNode != null) {
- sb.append("producer:\n");
- sb.append(" tps latency(ms) queue(ms) execute(ms) status
operation\n");
- for (Entry<String, MetricNode> operationNode :
producerNode.getChildren().entrySet()) {
- for (Entry<String, MetricNode> statusNode :
operationNode.getValue().getChildren().entrySet()) {
- sb.append(String.format(" %-7.0f %-11.3f %-9.3f %-11.3f %-7s
%s\n",
- statusNode.getValue()
-
.getFirstMatchMetricValue(Lists.newArrayList(MetricsConst.TAG_STAGE,
MetricsConst.TAG_STATISTIC),
- Lists.newArrayList(MetricsConst.STAGE_WHOLE, "tps")),
- statusNode.getValue()
-
.getFirstMatchMetricValue(Lists.newArrayList(MetricsConst.TAG_STAGE,
MetricsConst.TAG_STATISTIC),
- Lists.newArrayList(MetricsConst.STAGE_WHOLE,
"latency")),
- statusNode.getValue()
-
.getFirstMatchMetricValue(Lists.newArrayList(MetricsConst.TAG_STAGE,
MetricsConst.TAG_STATISTIC),
- Lists.newArrayList(MetricsConst.STAGE_QUEUE,
"latency")),
- statusNode.getValue()
-
.getFirstMatchMetricValue(Lists.newArrayList(MetricsConst.TAG_STAGE,
MetricsConst.TAG_STATISTIC),
- Lists.newArrayList(MetricsConst.STAGE_EXECUTION,
"latency")),
- statusNode.getKey(),
- operationNode.getKey()));
+ MetricNode producerNode =
treeNode.getChildren().get(String.valueOf(InvocationType.PRODUCER));
+ if (producerNode != null) {
+ sb.append("producer:\n");
+ sb.append(" tps latency(ms) queue(ms) execute(ms) status
operation\n");
+ for (Entry<String, MetricNode> operationNode :
producerNode.getChildren().entrySet()) {
+ for (Entry<String, MetricNode> statusNode :
operationNode.getValue().getChildren().entrySet()) {
+ sb.append(String.format(" %-7.0f %-11.3f %-9.3f %-11.3f %-7s
%s\n",
+ statusNode.getValue()
+ .getFirstMatchMetricValue(MetricsConst.TAG_STAGE,
MetricsConst.STAGE_TOTAL,
+ MetricsConst.TAG_STATISTIC, "tps"),
+ statusNode.getValue()
+ .getFirstMatchMetricValue(TimeUnit.MILLISECONDS,
MetricsConst.TAG_STAGE, MetricsConst.STAGE_TOTAL,
+ MetricsConst.TAG_STATISTIC, "latency"),
+ statusNode.getValue()
+ .getFirstMatchMetricValue(TimeUnit.MILLISECONDS,
MetricsConst.TAG_STAGE, MetricsConst.STAGE_QUEUE,
+ MetricsConst.TAG_STATISTIC, "latency"),
+ statusNode.getValue()
+ .getFirstMatchMetricValue(TimeUnit.MILLISECONDS,
MetricsConst.TAG_STAGE,
+ MetricsConst.STAGE_EXECUTION,
+ MetricsConst.TAG_STATISTIC, "latency"),
+ statusNode.getKey(), operationNode.getKey()));
+ }
}
}
}
+ } catch (ServiceCombException ignored) {
Review comment:
Why did you ignored the exception.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services