This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking.git
The following commit(s) were added to refs/heads/master by this push:
new 4d191993aa Fix `NPE` in metrics query when the metric is not exist.
(#10980)
4d191993aa is described below
commit 4d191993aaf3d074a72a77d40b04c85313e3f01a
Author: Wan Kai <[email protected]>
AuthorDate: Fri Jun 23 14:41:31 2023 +0800
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 <[email protected]>
---
.github/workflows/skywalking.yaml | 4 +-
docs/en/changes/changes.md | 3 +-
.../oap/query/graphql/resolver/MetricsQuery.java | 50 +++++++++++++---------
.../browser/browser-root.json | 2 +-
4 files changed, 34 insertions(+), 25 deletions(-)
diff --git a/.github/workflows/skywalking.yaml
b/.github/workflows/skywalking.yaml
index e4f80444d6..52226fb86e 100644
--- a/.github/workflows/skywalking.yaml
+++ b/.github/workflows/skywalking.yaml
@@ -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
diff --git a/docs/en/changes/changes.md b/docs/en/changes/changes.md
index 683bdeec14..0aa57650f5 100644
--- a/docs/en/changes/changes.md
+++ b/docs/en/changes/changes.md
@@ -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
diff --git
a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/MetricsQuery.java
b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/MetricsQuery.java
index 9bd7b03568..37687ff22b 100644
---
a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/MetricsQuery.java
+++
b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/MetricsQuery.java
@@ -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);
diff --git
a/oap-server/server-starter/src/main/resources/ui-initialized-templates/browser/browser-root.json
b/oap-server/server-starter/src/main/resources/ui-initialized-templates/browser/browser-root.json
index f8fdce713d..92edb7e853 100644
---
a/oap-server/server-starter/src/main/resources/ui-initialized-templates/browser/browser-root.json
+++
b/oap-server/server-starter/src/main/resources/ui-initialized-templates/browser/browser-root.json
@@ -40,7 +40,7 @@
},
"metrics": [
"browser_app_pv",
- "browser_app_error_rage"
+ "browser_app_error_rate"
],
"metricTypes": [
"readMetricsValues",