http api monitor command return timestamp. close #2320

This commit is contained in:
hengyunabc
2022-10-21 11:51:28 +08:00
parent 7637761fbb
commit f6fe8b9134
3 changed files with 16 additions and 2 deletions
@@ -160,6 +160,7 @@ class MonitorAdviceListener extends AdviceListenerAdapter {
MonitorData oData = value.get();
MonitorData nData = new MonitorData();
nData.setCost(oData.getCost() + cost);
nData.setTimestamp(new Date());
if (isThrowing) {
nData.setFailed(oData.getFailed() + 1);
nData.setSuccess(oData.getSuccess());
@@ -1,5 +1,7 @@
package com.taobao.arthas.core.command.monitor200;
import java.util.Date;
/**
* 数据监控用的value for MonitorCommand
*
@@ -12,6 +14,7 @@ public class MonitorData {
private int success;
private int failed;
private double cost;
private Date timestamp;
public String getClassName() {
return className;
@@ -60,4 +63,15 @@ public class MonitorData {
public void setCost(double cost) {
this.cost = cost;
}
public Date getTimestamp() {
if (timestamp == null) {
timestamp = new Date();
}
return timestamp;
}
public void setTimestamp(Date timestamp) {
this.timestamp = timestamp;
}
}
@@ -9,7 +9,6 @@ import com.taobao.text.util.RenderUtil;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import static com.taobao.text.ui.Element.label;
@@ -34,7 +33,7 @@ public class MonitorView extends ResultView<MonitorModel> {
for (MonitorData data : result.getMonitorDataList()) {
table.row(
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()),
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(data.getTimestamp()),
data.getClassName(),
data.getMethodName(),
"" + data.getTotal(),