|
@@ -4,11 +4,15 @@ import com.alibaba.fastjson2.JSONArray;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.jjt.biz.domain.*;
|
|
|
+import com.jjt.biz.mapper.AlarmRecordMapper;
|
|
|
+import com.jjt.biz.mapper.BizObjMetricsDataMapper;
|
|
|
import com.jjt.biz.mapper.BizObjMetricsMapper;
|
|
|
import com.jjt.biz.service.*;
|
|
|
import com.jjt.common.utils.DateUtils;
|
|
|
-import com.jjt.common.utils.IntervalUtil;
|
|
|
import com.jjt.common.utils.StringUtils;
|
|
|
+import com.jjt.hl.domain.HlEvent;
|
|
|
+import com.jjt.hl.mapper.HlEventMapper;
|
|
|
+import com.jjt.hl.service.IHlEventService;
|
|
|
import org.apache.ibatis.session.ExecutorType;
|
|
|
import org.apache.ibatis.session.SqlSession;
|
|
|
import org.apache.ibatis.session.SqlSessionFactory;
|
|
@@ -51,6 +55,8 @@ public class BizObjMetricsServiceImpl implements IBizObjMetricsService {
|
|
|
private IAlarmRecordService alarmRecordService;
|
|
|
@Resource
|
|
|
private IBizObjMetricsDataService metricsDataService;
|
|
|
+ @Resource
|
|
|
+ private IHlEventService eventService;
|
|
|
|
|
|
/**
|
|
|
* 查询业务对象指标
|
|
@@ -203,6 +209,7 @@ public class BizObjMetricsServiceImpl implements IBizObjMetricsService {
|
|
|
ms.setAlarmLow(d.getAlarmLow());
|
|
|
ms.setAlarmMid(d.getAlarmMid());
|
|
|
ms.setAlarmHigh(d.getAlarmHigh());
|
|
|
+ ms.setEvent(d.getEvent());
|
|
|
|
|
|
if (pp.getPpType().equals("REDIS")) {
|
|
|
//redis需要将1s换成100ms 3s换成300ms 5s换成500ms
|
|
@@ -234,6 +241,7 @@ public class BizObjMetricsServiceImpl implements IBizObjMetricsService {
|
|
|
ms.setAlarmLow(d.getAlarmLow());
|
|
|
ms.setAlarmMid(d.getAlarmMid());
|
|
|
ms.setAlarmHigh(d.getAlarmHigh());
|
|
|
+ ms.setEvent(d.getEvent());
|
|
|
objMetrics.add(ms);
|
|
|
}
|
|
|
});
|
|
@@ -256,20 +264,22 @@ public class BizObjMetricsServiceImpl implements IBizObjMetricsService {
|
|
|
om.setTplId(detail.getTplId());
|
|
|
|
|
|
List<BizObjMetrics> list = selectBizObjMetricsList(om);
|
|
|
- if (list.size() > 0) {
|
|
|
- list.forEach(obj -> {
|
|
|
- //如果有则更新,没有则插入
|
|
|
- obj.setAlarmMid(detail.getAlarmMid());
|
|
|
- obj.setAlarmLow(detail.getAlarmLow());
|
|
|
- obj.setAlarmHigh(detail.getAlarmHigh());
|
|
|
- bizObjMetricsMapper.updateBizObjMetrics(obj);
|
|
|
- });
|
|
|
- } else {
|
|
|
- om.setAlarmLow(detail.getAlarmLow());
|
|
|
- om.setAlarmMid(detail.getAlarmMid());
|
|
|
- om.setAlarmHigh(detail.getAlarmHigh());
|
|
|
- insertBizObjMetrics(om);
|
|
|
- }
|
|
|
+// if (list.size() > 0) {
|
|
|
+ list.forEach(obj -> {
|
|
|
+ //如果有则更新,没有则插入
|
|
|
+ obj.setAlarmMid(detail.getAlarmMid());
|
|
|
+ obj.setAlarmLow(detail.getAlarmLow());
|
|
|
+ obj.setAlarmHigh(detail.getAlarmHigh());
|
|
|
+ obj.setEvent(detail.getEvent());
|
|
|
+ bizObjMetricsMapper.updateBizObjMetrics(obj);
|
|
|
+ });
|
|
|
+// } else {
|
|
|
+// om.setAlarmLow(detail.getAlarmLow());
|
|
|
+// om.setAlarmMid(detail.getAlarmMid());
|
|
|
+// om.setAlarmHigh(detail.getAlarmHigh());
|
|
|
+// om.setEvent(detail.getEvent());
|
|
|
+// insertBizObjMetrics(om);
|
|
|
+// }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -290,9 +300,10 @@ public class BizObjMetricsServiceImpl implements IBizObjMetricsService {
|
|
|
* 根据objId获取指标值
|
|
|
*
|
|
|
* @param objId 对象ID
|
|
|
+ * @param date 数据时间
|
|
|
*/
|
|
|
@Override
|
|
|
- public void pinpointMetricsValue(Long objId) {
|
|
|
+ public void pinpointMetricsValue(Long objId, Date date) {
|
|
|
BizObj bizObj = objService.selectBizObjByObjId(objId);
|
|
|
|
|
|
if ("1".equals(bizObj.getObjType())) {
|
|
@@ -333,7 +344,7 @@ public class BizObjMetricsServiceImpl implements IBizObjMetricsService {
|
|
|
updateBizObjPpTable(objId, pinpointVOList);
|
|
|
|
|
|
// 2.更新业务对象指标表
|
|
|
- updateBizObjMetrics(objId, tps, openFiles, heapUsage, gcCount, pinpointVOList);
|
|
|
+ updateBizObjMetrics(objId, tps, openFiles, heapUsage, gcCount, pinpointVOList, date);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -341,70 +352,108 @@ public class BizObjMetricsServiceImpl implements IBizObjMetricsService {
|
|
|
* 根据objId获取prometheus指标值
|
|
|
*
|
|
|
* @param objId 对象ID
|
|
|
+ * @param date 时间
|
|
|
*/
|
|
|
@Override
|
|
|
- public void prometheusMetricsValue(Long objId) {
|
|
|
+ public void prometheusMetricsValue(Long objId, Date date) {
|
|
|
List<BizObjMetrics> mList = getAllMetricsForObjIdList(objId);
|
|
|
List<BizObjMetrics> metricsToUpdate = new ArrayList<>();
|
|
|
+ List<BizObjMetricsData> dataList = new ArrayList<>();
|
|
|
+ List<AlarmRecord> addRList = new ArrayList<>();
|
|
|
+ List<AlarmRecord> updateRList = new ArrayList<>();
|
|
|
+ List<HlEvent> addEList = new ArrayList<>();
|
|
|
+ List<HlEvent> updateEList = new ArrayList<>();
|
|
|
+ //查询当前对象所有正在告警列表
|
|
|
+ Map<Long, AlarmRecord> recordMap = alarmRecordService.selectAlarmRecordListCurr(objId);
|
|
|
+ //查询当前对象未结束事件列表
|
|
|
+ Map<Long, HlEvent> eventMap = eventService.selectHlEventListCurr(objId);
|
|
|
mList.stream().filter(om -> !"1".equals(om.getMetricsDef().getMetricsType())).forEach(om -> {
|
|
|
if (StringUtils.isNotEmpty(om.getDataExp())) {
|
|
|
//非pinpoint
|
|
|
Float value = prometheusService.query(om.getDataExp());
|
|
|
if (value != null) {
|
|
|
- String alarmLevel = getAlarmLevel(value, om);
|
|
|
om.setDValue(BigDecimal.valueOf(value));
|
|
|
-
|
|
|
- if (alarmLevel != null) {
|
|
|
- insertAlarm(om, alarmLevel);
|
|
|
- }
|
|
|
BizObjMetricsData data = new BizObjMetricsData();
|
|
|
data.setObjMetricsId(om.getObjMetricsId());
|
|
|
data.setdValue(om.getDValue());
|
|
|
- metricsDataService.insertBizObjMetricsData(data);
|
|
|
+ dataList.add(data);
|
|
|
metricsToUpdate.add(om);
|
|
|
+ //处理告警
|
|
|
+ Map<String, AlarmRecord> aMap = alarmRecordService.process(om, recordMap, date);
|
|
|
+ if (aMap.get("add") != null) {
|
|
|
+ addRList.add(aMap.get("add"));
|
|
|
+ }
|
|
|
+ if (aMap.get("update") != null) {
|
|
|
+ updateRList.add(aMap.get("update"));
|
|
|
+ }
|
|
|
+
|
|
|
+ //处理事件
|
|
|
+ Map<String, HlEvent> eMap = eventService.process(om, eventMap, date);
|
|
|
+ if (eMap.get("add") != null) {
|
|
|
+ addEList.add(eMap.get("add"));
|
|
|
+ }
|
|
|
+ if (eMap.get("update") != null) {
|
|
|
+ updateEList.add(eMap.get("update"));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- // 更新所有需要更新的BizObjMetrics对象
|
|
|
- metricsToUpdate.forEach(this::updateBizObjMetrics);
|
|
|
+ batchUpdate(metricsToUpdate, dataList, addRList, updateRList, addEList, updateEList);
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 获取告警等级
|
|
|
+ * 使用模拟数据
|
|
|
*
|
|
|
- * @param value 值
|
|
|
- * @param bizObjMetrics 指标对象
|
|
|
- * @return
|
|
|
+ * @param objId 对象ID
|
|
|
+ * @param date 数据时间
|
|
|
*/
|
|
|
- private String getAlarmLevel(Float value, BizObjMetrics bizObjMetrics) {
|
|
|
- if (StringUtils.isNotEmpty(bizObjMetrics.getAlarmLow()) && IntervalUtil.inNumRange(value, bizObjMetrics.getAlarmLow())) {
|
|
|
- return "low";
|
|
|
- } else if (StringUtils.isNotEmpty(bizObjMetrics.getAlarmMid()) && IntervalUtil.inNumRange(value, bizObjMetrics.getAlarmMid())) {
|
|
|
- return "mid";
|
|
|
- } else if (StringUtils.isNotEmpty(bizObjMetrics.getAlarmHigh()) && IntervalUtil.inNumRange(value, bizObjMetrics.getAlarmHigh())) {
|
|
|
- return "high";
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
+ @Override
|
|
|
+// @Async("threadPoolTaskExecutor")
|
|
|
+ public void imitate(Long objId, Date date) {
|
|
|
+ List<BizObjMetrics> mList = getAllMetricsForObjIdList(objId);
|
|
|
+ List<BizObjMetrics> metricsToUpdate = new ArrayList<>();
|
|
|
+ List<BizObjMetricsData> dataList = new ArrayList<>();
|
|
|
+ List<AlarmRecord> addRList = new ArrayList<>();
|
|
|
+ List<AlarmRecord> updateRList = new ArrayList<>();
|
|
|
+ List<HlEvent> addEList = new ArrayList<>();
|
|
|
+ List<HlEvent> updateEList = new ArrayList<>();
|
|
|
+ //查询当前对象所有正在告警列表
|
|
|
+ Map<Long, AlarmRecord> recordMap = alarmRecordService.selectAlarmRecordListCurr(objId);
|
|
|
+ //查询当前对象未结束事件列表
|
|
|
+ Map<Long, HlEvent> eventMap = eventService.selectHlEventListCurr(objId);
|
|
|
+
|
|
|
+ mList.stream().forEach(om -> {
|
|
|
+ Random random = new Random();
|
|
|
+ int xxx = (int) (om.getObjMetricsId() % 70);
|
|
|
+ float value = (float) random.nextInt(100 - xxx) + xxx;
|
|
|
+ om.setDValue(BigDecimal.valueOf(value));
|
|
|
+ BizObjMetricsData data = new BizObjMetricsData();
|
|
|
+ data.setObjMetricsId(om.getObjMetricsId());
|
|
|
+ data.setdValue(om.getDValue());
|
|
|
+ data.setCreateTime(date);
|
|
|
+// metricsDataService.insertBizObjMetricsData(data);
|
|
|
+ dataList.add(data);
|
|
|
+ metricsToUpdate.add(om);
|
|
|
+ //处理告警
|
|
|
+ Map<String, AlarmRecord> aMap = alarmRecordService.process(om, recordMap, date);
|
|
|
+ if (aMap.get("add") != null) {
|
|
|
+ addRList.add(aMap.get("add"));
|
|
|
+ }
|
|
|
+ if (aMap.get("update") != null) {
|
|
|
+ updateRList.add(aMap.get("update"));
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * 添加告警记录
|
|
|
- *
|
|
|
- * @param om 指标对象
|
|
|
- * @param alarmLevel 告警等级
|
|
|
- */
|
|
|
- private void insertAlarm(BizObjMetrics om, String alarmLevel) {
|
|
|
- //TODO 需要查询是否已经有告警记录
|
|
|
- // 1.如果该指标有告警,且告警等级相同,则不用管
|
|
|
- // 2.如果该指标有告警,但告警等级不同,则上一次告警结束,新增一条告警。
|
|
|
- AlarmRecord record = new AlarmRecord();
|
|
|
- record.setObjId(om.getObjId());
|
|
|
- record.setObjMetricsId(om.getObjMetricsId());
|
|
|
- record.setAlarmLevel(alarmLevel);
|
|
|
- record.setAlarmValue(om.getDValue());
|
|
|
- record.setAlarmTime(new Date());
|
|
|
- alarmRecordService.insertAlarmRecord(record);
|
|
|
+ //处理事件
|
|
|
+ Map<String, HlEvent> eMap = eventService.process(om, eventMap, date);
|
|
|
+ if (eMap.get("add") != null) {
|
|
|
+ addEList.add(eMap.get("add"));
|
|
|
+ }
|
|
|
+ if (eMap.get("update") != null) {
|
|
|
+ updateEList.add(eMap.get("update"));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ batchUpdate(metricsToUpdate, dataList, addRList, updateRList, addEList, updateEList);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -503,10 +552,11 @@ public class BizObjMetricsServiceImpl implements IBizObjMetricsService {
|
|
|
* @param heapUsage 堆内存使用率
|
|
|
* @param gcCount gc次数
|
|
|
* @param pinpointVOList 链路列表数据
|
|
|
+ * @param date 时间
|
|
|
*/
|
|
|
- private void updateBizObjMetrics(Long objId, Float tps, int openFiles, float heapUsage, int gcCount, List<PinpointVO> pinpointVOList) {
|
|
|
- updateJvmMetrics(objId, tps, heapUsage, openFiles, gcCount);
|
|
|
- updateLinkMetrics(objId, pinpointVOList);
|
|
|
+ private void updateBizObjMetrics(Long objId, Float tps, int openFiles, float heapUsage, int gcCount, List<PinpointVO> pinpointVOList, Date date) {
|
|
|
+ updateJvmMetrics(objId, tps, heapUsage, openFiles, gcCount, date);
|
|
|
+ updateLinkMetrics(objId, pinpointVOList, date);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -517,16 +567,21 @@ public class BizObjMetricsServiceImpl implements IBizObjMetricsService {
|
|
|
* @param openFiles 打开文件数量
|
|
|
* @param heapUsage 堆内存使用率
|
|
|
* @param gcCount gc次数
|
|
|
+ * @param date 数据时间
|
|
|
*/
|
|
|
- private void updateJvmMetrics(Long objId, Float tps, float heapUsage, int openFiles, int gcCount) {
|
|
|
+ private void updateJvmMetrics(Long objId, Float tps, float heapUsage, int openFiles, int gcCount, Date date) {
|
|
|
BizObjMetrics jvmMetrics = new BizObjMetrics();
|
|
|
jvmMetrics.setObjId(objId);
|
|
|
+ //查询当前对象所有正在告警列表
|
|
|
+ Map<Long, AlarmRecord> recordMap = alarmRecordService.selectAlarmRecordListCurr(objId);
|
|
|
+ //查询当前对象未结束事件列表
|
|
|
+ Map<Long, HlEvent> eventMap = eventService.selectHlEventListCurr(objId);
|
|
|
jvmMetrics.setMetricsCode("pp.jvm.");
|
|
|
List<BizObjMetrics> omList = selectBizObjMetricsList(jvmMetrics);
|
|
|
- updateMetricsValues(omList, "tps", BigDecimal.valueOf(tps));
|
|
|
- updateMetricsValues(omList, "heap.usage", BigDecimal.valueOf(heapUsage));
|
|
|
- updateMetricsValues(omList, "open", BigDecimal.valueOf(openFiles));
|
|
|
- updateMetricsValues(omList, "gc", BigDecimal.valueOf(gcCount));
|
|
|
+ updateMetricsValues(omList, "tps", BigDecimal.valueOf(tps), date, recordMap, eventMap);
|
|
|
+ updateMetricsValues(omList, "heap.usage", BigDecimal.valueOf(heapUsage), date, recordMap, eventMap);
|
|
|
+ updateMetricsValues(omList, "open", BigDecimal.valueOf(openFiles), date, recordMap, eventMap);
|
|
|
+ updateMetricsValues(omList, "gc", BigDecimal.valueOf(gcCount), date, recordMap, eventMap);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -535,23 +590,71 @@ public class BizObjMetricsServiceImpl implements IBizObjMetricsService {
|
|
|
* @param omList jvm指标列表
|
|
|
* @param metricSuffix 指标后缀
|
|
|
* @param value 值
|
|
|
+ * @param date 数据时间
|
|
|
*/
|
|
|
- private void updateMetricsValues(List<BizObjMetrics> omList, String metricSuffix, BigDecimal value) {
|
|
|
+ private void updateMetricsValues(List<BizObjMetrics> omList, String metricSuffix, BigDecimal value, Date date, Map<Long, AlarmRecord> recordMap, Map<Long, HlEvent> eventMap) {
|
|
|
+ List<BizObjMetricsData> dataList = new ArrayList<>();
|
|
|
+ List<AlarmRecord> addRList = new ArrayList<>();
|
|
|
+ List<AlarmRecord> updateRList = new ArrayList<>();
|
|
|
+ List<HlEvent> addEList = new ArrayList<>();
|
|
|
+ List<HlEvent> updateEList = new ArrayList<>();
|
|
|
omList.stream()
|
|
|
.filter(om -> om.getMetricsCode().endsWith(metricSuffix))
|
|
|
.forEach(om -> {
|
|
|
- //TODO 独立出一个告警处理方法出来
|
|
|
- String alarmLevel = getAlarmLevel(value.floatValue(), om);
|
|
|
- if (alarmLevel != null) {
|
|
|
- insertAlarm(om, alarmLevel);
|
|
|
- }
|
|
|
om.setDValue(value);
|
|
|
updateBizObjMetrics(om);
|
|
|
BizObjMetricsData data = new BizObjMetricsData();
|
|
|
data.setObjMetricsId(om.getObjMetricsId());
|
|
|
data.setdValue(om.getDValue());
|
|
|
- metricsDataService.insertBizObjMetricsData(data);
|
|
|
+ dataList.add(data);
|
|
|
+ //处理告警
|
|
|
+ Map<String, AlarmRecord> aMap = alarmRecordService.process(om, recordMap, date);
|
|
|
+ if (aMap.get("add") != null) {
|
|
|
+ addRList.add(aMap.get("add"));
|
|
|
+ }
|
|
|
+ if (aMap.get("update") != null) {
|
|
|
+ updateRList.add(aMap.get("update"));
|
|
|
+ }
|
|
|
+
|
|
|
+ //处理事件
|
|
|
+ Map<String, HlEvent> eMap = eventService.process(om, eventMap, date);
|
|
|
+ if (eMap.get("add") != null) {
|
|
|
+ addEList.add(eMap.get("add"));
|
|
|
+ }
|
|
|
+ if (eMap.get("update") != null) {
|
|
|
+ updateEList.add(eMap.get("update"));
|
|
|
+ }
|
|
|
});
|
|
|
+ batchUpdate(null, dataList, addRList, updateRList, addEList, updateEList);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void batchUpdate(List<BizObjMetrics> metricsToUpdate, List<BizObjMetricsData> dataList, List<AlarmRecord> addRList, List<AlarmRecord> updateRList, List<HlEvent> addEList, List<HlEvent> updateEList) {
|
|
|
+ // 更新所有需要更新的BizObjMetrics对象
|
|
|
+ try (SqlSession sqlSession = factory.openSession(ExecutorType.BATCH, false)) {
|
|
|
+ BizObjMetricsMapper mapper = sqlSession.getMapper(BizObjMetricsMapper.class);
|
|
|
+ if (metricsToUpdate != null && metricsToUpdate.size() > 0) {
|
|
|
+ metricsToUpdate.forEach(mapper::updateBizObjMetrics);
|
|
|
+ }
|
|
|
+ if (dataList != null && dataList.size() > 0) {
|
|
|
+ BizObjMetricsDataMapper dataMapper = sqlSession.getMapper(BizObjMetricsDataMapper.class);
|
|
|
+ dataList.forEach(dataMapper::insertBizObjMetricsData);
|
|
|
+ }
|
|
|
+ AlarmRecordMapper recordMapper = sqlSession.getMapper(AlarmRecordMapper.class);
|
|
|
+ if (addRList != null && addRList.size() > 0) {
|
|
|
+ addRList.forEach(recordMapper::insertAlarmRecord);
|
|
|
+ }
|
|
|
+ if (updateRList != null && updateRList.size() > 0) {
|
|
|
+ updateRList.forEach(recordMapper::updateAlarmRecord);
|
|
|
+ }
|
|
|
+ HlEventMapper eventMapper = sqlSession.getMapper(HlEventMapper.class);
|
|
|
+ if (addEList != null && addEList.size() > 0) {
|
|
|
+ addEList.forEach(eventMapper::insertHlEvent);
|
|
|
+ }
|
|
|
+ if (updateEList != null && updateEList.size() > 0) {
|
|
|
+ updateEList.forEach(eventMapper::updateHlEvent);
|
|
|
+ }
|
|
|
+ sqlSession.commit();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -559,10 +662,11 @@ public class BizObjMetricsServiceImpl implements IBizObjMetricsService {
|
|
|
*
|
|
|
* @param objId 对象ID
|
|
|
* @param pinpointVOList 链路列表
|
|
|
+ * @param date 时间
|
|
|
*/
|
|
|
- private void updateLinkMetrics(Long objId, List<PinpointVO> pinpointVOList) {
|
|
|
+ private void updateLinkMetrics(Long objId, List<PinpointVO> pinpointVOList, Date date) {
|
|
|
Map<String, BizObjMetrics> metricsMap = getAllMetricsForObjId(objId);
|
|
|
- pinpointVOList.forEach(vo -> updateMetricsValues(metricsMap, vo));
|
|
|
+ pinpointVOList.forEach(vo -> updateMetricsValues(metricsMap, vo, date));
|
|
|
}
|
|
|
|
|
|
|
|
@@ -571,23 +675,24 @@ public class BizObjMetricsServiceImpl implements IBizObjMetricsService {
|
|
|
*
|
|
|
* @param metricsMap 指标map
|
|
|
* @param vo pp链路对象
|
|
|
+ * @param date 时间
|
|
|
*/
|
|
|
- private void updateMetricsValues(Map<String, BizObjMetrics> metricsMap, PinpointVO vo) {
|
|
|
+ private void updateMetricsValues(Map<String, BizObjMetrics> metricsMap, PinpointVO vo, Date date) {
|
|
|
metricsMap.values().stream()
|
|
|
.filter(om -> om.getMetricsCode().startsWith(vo.getApplicationName() + "/"))
|
|
|
.forEach(om -> {
|
|
|
- updateMetric(om, "pp.1s", vo.getTime1s());
|
|
|
- updateMetric(om, "pp.3s", vo.getTime3s());
|
|
|
- updateMetric(om, "pp.5s", vo.getTime5s());
|
|
|
- updateMetric(om, "pp.100ms", vo.getTime100ms());
|
|
|
- updateMetric(om, "pp.300ms", vo.getTime300ms());
|
|
|
- updateMetric(om, "pp.500ms", vo.getTime500ms());
|
|
|
- updateMetric(om, "pp.tot", vo.getTot());
|
|
|
- updateMetric(om, "pp.sum", vo.getSum());
|
|
|
- updateMetric(om, "pp.max", vo.getMax());
|
|
|
- updateMetric(om, "pp.avg", vo.getAvg());
|
|
|
- updateMetric(om, "pp.slow", vo.getSlow());
|
|
|
- updateMetric(om, "pp.error", vo.getError());
|
|
|
+ updateMetric(om, "pp.1s", vo.getTime1s(), date);
|
|
|
+ updateMetric(om, "pp.3s", vo.getTime3s(), date);
|
|
|
+ updateMetric(om, "pp.5s", vo.getTime5s(), date);
|
|
|
+ updateMetric(om, "pp.100ms", vo.getTime100ms(), date);
|
|
|
+ updateMetric(om, "pp.300ms", vo.getTime300ms(), date);
|
|
|
+ updateMetric(om, "pp.500ms", vo.getTime500ms(), date);
|
|
|
+ updateMetric(om, "pp.tot", vo.getTot(), date);
|
|
|
+ updateMetric(om, "pp.sum", vo.getSum(), date);
|
|
|
+ updateMetric(om, "pp.max", vo.getMax(), date);
|
|
|
+ updateMetric(om, "pp.avg", vo.getAvg(), date);
|
|
|
+ updateMetric(om, "pp.slow", vo.getSlow(), date);
|
|
|
+ updateMetric(om, "pp.error", vo.getError(), date);
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -597,14 +702,16 @@ public class BizObjMetricsServiceImpl implements IBizObjMetricsService {
|
|
|
* @param om 对象
|
|
|
* @param suffix 前缘
|
|
|
* @param value 值
|
|
|
+ * @param date 时间
|
|
|
*/
|
|
|
- private void updateMetric(BizObjMetrics om, String suffix, Number value) {
|
|
|
+ private void updateMetric(BizObjMetrics om, String suffix, Number value, Date date) {
|
|
|
if (om.getMetricsCode().endsWith(suffix) && value != null) {
|
|
|
om.setDValue(BigDecimal.valueOf(value.doubleValue()));
|
|
|
updateBizObjMetrics(om);
|
|
|
BizObjMetricsData data = new BizObjMetricsData();
|
|
|
data.setObjMetricsId(om.getObjMetricsId());
|
|
|
data.setdValue(om.getDValue());
|
|
|
+ data.setCreateTime(date);
|
|
|
metricsDataService.insertBizObjMetricsData(data);
|
|
|
}
|
|
|
}
|