|
@@ -11,6 +11,7 @@ import com.jjt.biz.service.*;
|
|
|
import com.jjt.common.exception.ServiceException;
|
|
|
import com.jjt.common.utils.DateUtils;
|
|
|
import com.jjt.common.utils.StringUtils;
|
|
|
+import com.jjt.common.utils.bean.BeanUtils;
|
|
|
import com.jjt.hl.domain.HlEvent;
|
|
|
import com.jjt.hl.mapper.HlEventMapper;
|
|
|
import com.jjt.hl.service.IHlEventService;
|
|
@@ -201,7 +202,7 @@ public class BizObjMetricsServiceImpl implements IBizObjMetricsService {
|
|
|
List<MetricsTplDetail> list = detailService.selectMetricsTplDetailList(query);
|
|
|
List<BizObjMetrics> objMetrics = new ArrayList<>();
|
|
|
list.forEach(d -> {
|
|
|
- if ("1".equals(d.getMetricsDef().getMetricsType()) && !d.getMetricsDef().getMetricsCode().startsWith("pp.jvm.")) {
|
|
|
+ if ("1".equals(d.getMetricsDef().getMetricsType()) && !d.getMetricsDef().getMetricsCode().startsWith("pp.jvm.")) {
|
|
|
//如果是pinpoint,并且不是jvm参数
|
|
|
// 1.获取对象pinpoint组成
|
|
|
List<BizObjPp> pps = ppService.selectBizObjPpListByObjId(objId);
|
|
@@ -212,8 +213,8 @@ public class BizObjMetricsServiceImpl implements IBizObjMetricsService {
|
|
|
ms.setTplId(tplId);
|
|
|
ms.setMetricsId(d.getMetricsId());
|
|
|
ms.setMetricsName(pp.getPpType() + "/" + d.getMetricsDef().getMetricsName());
|
|
|
- ms.setMetricsCode(d.getMetricsCode());
|
|
|
- ms.setDataExp(ms.getMetricsCode());
|
|
|
+ ms.setMetricsCode(d.getMetricsDef().getMetricsCode());
|
|
|
+ ms.setDataExp(d.getMetricsDef().getMetricsCode());
|
|
|
ms.setAlarmLow(d.getAlarmLow());
|
|
|
ms.setAlarmMid(d.getAlarmMid());
|
|
|
ms.setAlarmHigh(d.getAlarmHigh());
|
|
@@ -260,9 +261,12 @@ public class BizObjMetricsServiceImpl implements IBizObjMetricsService {
|
|
|
String v = metric.getJSONObject(i).getByPath("metric." + d.getFindKey(), String.class);
|
|
|
String name = d.getMetricsDef().getMetricsName() + "{" + d.getFindKey() + "=" + v + "}";
|
|
|
String dataExp = ms.getDataExp().replace("${key}", v);
|
|
|
- ms.setDataExp(dataExp);
|
|
|
- ms.setMetricsName(name);
|
|
|
- objMetrics.add(ms);
|
|
|
+ BizObjMetrics newMs = new BizObjMetrics();
|
|
|
+ BeanUtils.copyProperties(ms, newMs);
|
|
|
+ newMs.setObjMetricsId(null);
|
|
|
+ newMs.setDataExp(dataExp);
|
|
|
+ newMs.setMetricsName(name);
|
|
|
+ objMetrics.add(newMs);
|
|
|
}
|
|
|
} else {
|
|
|
objMetrics.add(ms);
|
|
@@ -336,8 +340,7 @@ public class BizObjMetricsServiceImpl implements IBizObjMetricsService {
|
|
|
|
|
|
if ("1".equals(bizObj.getObjType())) {
|
|
|
// 获取应用程序的code
|
|
|
- BizObjApp app = appService.selectBizObjAppByAppId(bizObj.getAppId());
|
|
|
- String appName = app.getAppCode();
|
|
|
+ String appName = bizObj.getObjAddr();
|
|
|
|
|
|
Long time = Long.parseLong(configService.selectConfigByKey("pp.api.time"));
|
|
|
LocalDateTime endTime = LocalDateTime.now();
|
|
@@ -571,6 +574,11 @@ public class BizObjMetricsServiceImpl implements IBizObjMetricsService {
|
|
|
ms.setObjId(objId);
|
|
|
ms.setTplId(-1L);
|
|
|
ms.setMetricsId(d.getMetricsId());
|
|
|
+
|
|
|
+ List<BizObjMetrics> queryList = bizObjMetricsMapper.selectBizObjMetricsList(ms);
|
|
|
+ if (queryList.size() > 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
ms.setMetricsName(d.getMetricsName());
|
|
|
ms.setMetricsCode(d.getMetricsCode());
|
|
|
ms.setAlarmLow(d.getAlarmLow());
|
|
@@ -590,9 +598,12 @@ public class BizObjMetricsServiceImpl implements IBizObjMetricsService {
|
|
|
String v = metric.getJSONObject(i).getByPath("metric." + d.getFindKey(), String.class);
|
|
|
String name = d.getMetricsName() + "{" + d.getFindKey() + "=" + v + "}";
|
|
|
String dataExp = ms.getDataExp().replace("${key}", v);
|
|
|
- ms.setDataExp(dataExp);
|
|
|
- ms.setMetricsName(name);
|
|
|
- objMetrics.add(ms);
|
|
|
+ BizObjMetrics newMs = new BizObjMetrics();
|
|
|
+ BeanUtils.copyProperties(ms, newMs);
|
|
|
+ newMs.setObjMetricsId(null);
|
|
|
+ newMs.setDataExp(dataExp);
|
|
|
+ newMs.setMetricsName(name);
|
|
|
+ objMetrics.add(newMs);
|
|
|
}
|
|
|
} else {
|
|
|
objMetrics.add(ms);
|
|
@@ -689,8 +700,9 @@ public class BizObjMetricsServiceImpl implements IBizObjMetricsService {
|
|
|
objMetrics.add(ms);
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
- bizObjMetricsMapper.batchInsert(objMetrics);
|
|
|
+ if (objMetrics.size() > 0) {
|
|
|
+ bizObjMetricsMapper.batchInsert(objMetrics);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -846,7 +858,11 @@ public class BizObjMetricsServiceImpl implements IBizObjMetricsService {
|
|
|
updateMetric(om, "pp.avg", vo.getAvg(), date);
|
|
|
updateMetric(om, "pp.slow", vo.getSlow(), date);
|
|
|
updateMetric(om, "pp.error", vo.getError(), date);
|
|
|
- BigDecimal rate = BigDecimal.valueOf(vo.getTime1s()).divide(BigDecimal.valueOf(vo.getTot()), 2, RoundingMode.HALF_UP);
|
|
|
+ Integer time1 = vo.getTime1s();
|
|
|
+ if (time1 == null) {
|
|
|
+ time1 = vo.getTime100ms();
|
|
|
+ }
|
|
|
+ BigDecimal rate = BigDecimal.valueOf(time1).divide(BigDecimal.valueOf(vo.getTot()), 2, RoundingMode.HALF_UP);
|
|
|
updateMetric(om, "pp.rate", rate, date);
|
|
|
}
|
|
|
}
|