This is an automated email from the ASF dual-hosted git repository. wusheng pushed a commit to branch es-bug in repository https://gitbox.apache.org/repos/asf/skywalking.git
commit 15c89c3755a37958bdcee17b45de3be123bc87cb Author: Wu Sheng <[email protected]> AuthorDate: Tue Oct 26 21:27:17 2021 +0800 Fix ElasticSearch implementation of `queryMetricsValues` and `readLabeledMetricsValues` doesn't fill default values --- CHANGES.md | 37 ++++++++------- oap-server/server-starter/pom.xml | 19 +------- .../elasticsearch/query/MetricsQueryEsDAO.java | 55 ++++++++++------------ 3 files changed, 48 insertions(+), 63 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index b7e85d7..aca658b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,26 +4,27 @@ Release Notes. 8.9.0 ------------------ + #### Project * Replace e2e cases to e2e-v2: - - Simple: JDK, Auth, SSL, mTLS - - Lua Nginx - - SelfObservability - - Gateway - - Meter - - Nodejs - - PHP - - VM: Prometheus Node Exporter, Zabbix - - go2sky - - log - - Python - - Storage - - Cluster - - Event - - Profile - - Kafka: Base, Meter, Log, Profile - - Client-JS + - Simple: JDK, Auth, SSL, mTLS + - Lua Nginx + - SelfObservability + - Gateway + - Meter + - Nodejs + - PHP + - VM: Prometheus Node Exporter, Zabbix + - go2sky + - log + - Python + - Storage + - Cluster + - Event + - Profile + - Kafka: Base, Meter, Log, Profile + - Client-JS * Support JDK 16 and 17. #### OAP Server @@ -55,6 +56,8 @@ Release Notes. * Fix unexpected deleting due to TTL mechanism bug for H2, MySQL, TiDB and PostgreSQL. * Add a GraphQL query to get OAP version, display OAP version in startup message and error logs. * Fix TimeBucket missing in H2, MySQL, TiDB and PostgreSQL bug, which causes TTL doesn't work for `service_traffic`. +* Fix ElasticSearch implementation of `queryMetricsValues` and `readLabeledMetricsValues` doesn't fill default values + when no available data in the ElasticSearch server. #### UI diff --git a/oap-server/server-starter/pom.xml b/oap-server/server-starter/pom.xml index 3468f83..b9ef3e4 100644 --- a/oap-server/server-starter/pom.xml +++ b/oap-server/server-starter/pom.xml @@ -29,7 +29,8 @@ <artifactId>server-starter</artifactId> <properties> - <generateGitPropertiesFilename>${project.build.outputDirectory}/version.properties</generateGitPropertiesFilename> + <generateGitPropertiesFilename>${project.build.outputDirectory}/version.properties + </generateGitPropertiesFilename> </properties> <dependencies> @@ -265,22 +266,6 @@ <build> <finalName>skywalking-oap</finalName> - <resources> - <resource> - <directory>src/main/resources</directory> - <filtering>true</filtering> - <includes> - <include>version.properties</include> - </includes> - </resource> - <resource> - <directory>src/main/resources</directory> - <filtering>false</filtering> - <excludes> - <exclude>version.properties</exclude> - </excludes> - </resource> - </resources> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetricsQueryEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetricsQueryEsDAO.java index e3f9f44..38619c5 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetricsQueryEsDAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetricsQueryEsDAO.java @@ -19,7 +19,6 @@ package org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -107,33 +106,31 @@ public class MetricsQueryEsDAO extends EsDAO implements IMetricsQueryDAO { } return id; }).collect(Collectors.toList()); + MetricsValues metricsValues = new MetricsValues(); SearchResponse response = getClient().ids(tableName, ids); - if (response.getHits().getHits().isEmpty()) { - return metricsValues; - } - - Map<String, Map<String, Object>> idMap = toMap(response.getHits()); - - // Label is null, because in readMetricsValues, no label parameter. - IntValues intValues = metricsValues.getValues(); - for (String id : ids) { - KVInt kvInt = new KVInt(); - kvInt.setId(id); - kvInt.setValue(0); - if (idMap.containsKey(id)) { - Map<String, Object> source = idMap.get(id); - kvInt.setValue(((Number) source.getOrDefault(valueColumnName, 0)).longValue()); - } else { - kvInt.setValue(ValueColumnMetadata.INSTANCE.getDefaultValue(condition.getName())); + if (!response.getHits().getHits().isEmpty()) { + Map<String, Map<String, Object>> idMap = toMap(response.getHits()); + + // Label is null, because in readMetricsValues, no label parameter. + IntValues intValues = metricsValues.getValues(); + for (String id : ids) { + KVInt kvInt = new KVInt(); + kvInt.setId(id); + kvInt.setValue(0); + if (idMap.containsKey(id)) { + Map<String, Object> source = idMap.get(id); + kvInt.setValue(((Number) source.getOrDefault(valueColumnName, 0)).longValue()); + } else { + kvInt.setValue(ValueColumnMetadata.INSTANCE.getDefaultValue(condition.getName())); + } + intValues.addKVInt(kvInt); } - intValues.addKVInt(kvInt); } - metricsValues.setValues( Util.sortValues( - intValues, ids, ValueColumnMetadata.INSTANCE.getDefaultValue(condition.getName())) + metricsValues.getValues(), ids, ValueColumnMetadata.INSTANCE.getDefaultValue(condition.getName())) ); return metricsValues; @@ -158,15 +155,15 @@ public class MetricsQueryEsDAO extends EsDAO implements IMetricsQueryDAO { }); SearchResponse response = getClient().ids(tableName, ids); - if (response.getHits().getHits().isEmpty()) { - return Collections.emptyList(); - } Map<String, DataTable> idMap = new HashMap<>(); - for (final SearchHit hit : response.getHits()) { - idMap.put( - hit.getId(), - new DataTable((String) hit.getSource().getOrDefault(valueColumnName, "")) - ); + + if (!response.getHits().getHits().isEmpty()) { + for (final SearchHit hit : response.getHits()) { + idMap.put( + hit.getId(), + new DataTable((String) hit.getSource().getOrDefault(valueColumnName, "")) + ); + } } return Util.composeLabelValue(condition, labels, ids, idMap); }
