优化agent本地存储流量数据处理
This commit is contained in:
+14
-5
@@ -118,7 +118,6 @@ public class EchartsDataUtils {
|
||||
// 准备X轴和Y轴数据
|
||||
List<String> xAxisData = new ArrayList<>();
|
||||
Map<String, Object> yData = new LinkedHashMap<>();
|
||||
|
||||
// 初始化Y轴数据结构
|
||||
dataExtractors.keySet().forEach(name ->
|
||||
yData.put(name, new ArrayList<>()));
|
||||
@@ -152,7 +151,7 @@ public class EchartsDataUtils {
|
||||
seriesData.add(getDefaultValue(name, fixedPercentile95Value, xAxisData.size()-1, hasRealData));
|
||||
} else {
|
||||
// 在数据时间范围外
|
||||
seriesData.add(getEmptyDataDefaultValue(name, xAxisData.size()-1));
|
||||
seriesData.add(getEmptyDataDefaultValue(name, xAxisData.size()-1, hasRealData));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -338,13 +337,23 @@ public class EchartsDataUtils {
|
||||
/**
|
||||
* 获取空数据默认值(用于数据时间范围外的点)
|
||||
*/
|
||||
private static Object getEmptyDataDefaultValue(String metricName, int timeIndex) {
|
||||
private static Object getEmptyDataDefaultValue(String metricName, int timeIndex, boolean hasRealData) {
|
||||
// deployDevice特殊处理:始终补空字符串
|
||||
if ("deployDevice".equals(metricName)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return null;
|
||||
// 智能补全策略
|
||||
if (hasRealData) {
|
||||
// 数据集中有真实数据:所有缺失点都补null
|
||||
return null;
|
||||
} else {
|
||||
// 数据集中没有真实数据:第一个点补0,其他点补null
|
||||
if (timeIndex == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user