Fix `NPE` in metrics query when the metric is not exist. (#10980)
* Fix `NPE` in metrics query when the metric is not exist. * Fix metric name `browser_app_error_rate` in `Browser-Root` dashboard. * Exclude istio 1.7 from testing again. --------- Co-authored-by: 吴晟 Wu Sheng <wu.sheng@foxmail.com>
This commit is contained in:
parent
cf696ab698
commit
4d191993aa
|
|
@ -750,8 +750,8 @@ jobs:
|
|||
matrix:
|
||||
analyzer: [k8s-mesh, mx-mesh]
|
||||
versions:
|
||||
- istio: 1.7.1
|
||||
kubernetes: 18
|
||||
#- istio: 1.7.1
|
||||
# kubernetes: 18
|
||||
- istio: 1.8.2
|
||||
kubernetes: 19
|
||||
- istio: 1.9.1
|
||||
|
|
|
|||
|
|
@ -14,9 +14,10 @@
|
|||
* Remove patterns from `HttpUriRecognitionService#feedRawData` and add max 10 candidates of raw URIs for each pattern.
|
||||
* Add component ID for WebSphere.
|
||||
* Fix AI Pipeline uri caching NullPointer and IllegalArgument Exceptions.
|
||||
* Fix `NPE` in metrics query when the metric is not exist.
|
||||
|
||||
#### UI
|
||||
|
||||
* Fix metric name `browser_app_error_rate` in `Browser-Root` dashboard.
|
||||
|
||||
#### Documentation
|
||||
|
||||
|
|
|
|||
|
|
@ -137,19 +137,22 @@ public class MetricsQuery implements GraphQLQueryResolver {
|
|||
* Read time-series values in the duration of required metrics
|
||||
*/
|
||||
public MetricsValues readMetricsValues(MetricsCondition condition, Duration duration) throws IOException {
|
||||
if (!condition.senseScope() || !condition.getEntity().isValid()) {
|
||||
boolean hasScope = condition.senseScope();
|
||||
if (!hasScope || !condition.getEntity().isValid()) {
|
||||
final List<PointOfTime> pointOfTimes = duration.assembleDurationPoints();
|
||||
String entityId = "UNKNOWN_METRIC_NAME";
|
||||
if (hasScope) {
|
||||
entityId = "ILLEGAL_ENTITY";
|
||||
}
|
||||
MetricsValues values = new MetricsValues();
|
||||
pointOfTimes.forEach(pointOfTime -> {
|
||||
String id = pointOfTime.id(
|
||||
condition.getEntity().isValid() ? condition.getEntity().buildId() : "ILLEGAL_ENTITY"
|
||||
);
|
||||
for (PointOfTime pointOfTime : pointOfTimes) {
|
||||
String id = pointOfTime.id(entityId);
|
||||
final KVInt kvInt = new KVInt();
|
||||
kvInt.setId(id);
|
||||
kvInt.setValue(0);
|
||||
kvInt.setEmptyValue(true);
|
||||
values.getValues().addKVInt(kvInt);
|
||||
});
|
||||
}
|
||||
return values;
|
||||
}
|
||||
return getMetricsQueryService().readMetricsValues(condition, duration);
|
||||
|
|
@ -173,25 +176,27 @@ public class MetricsQuery implements GraphQLQueryResolver {
|
|||
public List<MetricsValues> readLabeledMetricsValues(MetricsCondition condition,
|
||||
List<String> labels,
|
||||
Duration duration) throws IOException {
|
||||
if (!condition.senseScope() || !condition.getEntity().isValid()) {
|
||||
boolean hasScope = condition.senseScope();
|
||||
if (!hasScope || !condition.getEntity().isValid()) {
|
||||
final List<PointOfTime> pointOfTimes = duration.assembleDurationPoints();
|
||||
|
||||
String entityId = "UNKNOWN_METRIC_NAME";
|
||||
if (hasScope) {
|
||||
entityId = "ILLEGAL_ENTITY";
|
||||
}
|
||||
List<MetricsValues> labeledValues = new ArrayList<>(labels.size());
|
||||
labels.forEach(label -> {
|
||||
for (String label : labels) {
|
||||
MetricsValues values = new MetricsValues();
|
||||
pointOfTimes.forEach(pointOfTime -> {
|
||||
String id = pointOfTime.id(
|
||||
condition.getEntity().isValid() ? condition.getEntity().buildId() : "ILLEGAL_ENTITY"
|
||||
);
|
||||
for (PointOfTime pointOfTime : pointOfTimes) {
|
||||
String id = pointOfTime.id(entityId);
|
||||
final KVInt kvInt = new KVInt();
|
||||
kvInt.setId(id);
|
||||
kvInt.setValue(0);
|
||||
kvInt.setEmptyValue(true);
|
||||
values.getValues().addKVInt(kvInt);
|
||||
});
|
||||
}
|
||||
values.setLabel(label);
|
||||
labeledValues.add(values);
|
||||
});
|
||||
}
|
||||
return labeledValues;
|
||||
}
|
||||
return getMetricsQueryService().readLabeledMetricsValues(condition, labels, duration);
|
||||
|
|
@ -210,18 +215,21 @@ public class MetricsQuery implements GraphQLQueryResolver {
|
|||
* </pre>
|
||||
*/
|
||||
public HeatMap readHeatMap(MetricsCondition condition, Duration duration) throws IOException {
|
||||
if (!condition.senseScope() || !condition.getEntity().isValid()) {
|
||||
boolean hasScope = condition.senseScope();
|
||||
if (!hasScope || !condition.getEntity().isValid()) {
|
||||
DataTable emptyData = new DataTable();
|
||||
emptyData.put("0", 0L);
|
||||
final String rawdata = emptyData.toStorageData();
|
||||
final HeatMap heatMap = new HeatMap();
|
||||
final List<PointOfTime> pointOfTimes = duration.assembleDurationPoints();
|
||||
pointOfTimes.forEach(pointOfTime -> {
|
||||
String id = pointOfTime.id(
|
||||
condition.getEntity().isValid() ? condition.getEntity().buildId() : "ILLEGAL_ENTITY"
|
||||
);
|
||||
String entityId = "UNKNOWN_METRIC_NAME";
|
||||
if (hasScope) {
|
||||
entityId = "ILLEGAL_ENTITY";
|
||||
}
|
||||
for (PointOfTime pointOfTime : pointOfTimes) {
|
||||
String id = pointOfTime.id(entityId);
|
||||
heatMap.buildColumn(id, rawdata, 0);
|
||||
});
|
||||
}
|
||||
return heatMap;
|
||||
}
|
||||
return getMetricsQueryService().readHeatMap(condition, duration);
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
},
|
||||
"metrics": [
|
||||
"browser_app_pv",
|
||||
"browser_app_error_rage"
|
||||
"browser_app_error_rate"
|
||||
],
|
||||
"metricTypes": [
|
||||
"readMetricsValues",
|
||||
|
|
|
|||
Loading…
Reference in New Issue