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