未验证 提交 2ea12934 编写于 作者: wu-sheng's avatar wu-sheng 提交者: GitHub

Fix ElasticSearch implementation of `queryMetricsValues` and...

Fix ElasticSearch implementation of `queryMetricsValues` and `readLabeledMetricsValues` doesn't fill default values (#8012)

* Fix ElasticSearch implementation of `queryMetricsValues` and `readLabeledMetricsValues` doesn't fill default values
* Change generated file path.
上级 f7bcb767
......@@ -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
......
......@@ -29,7 +29,8 @@
<artifactId>server-starter</artifactId>
<properties>
<generateGitPropertiesFilename>${project.build.outputDirectory}/version.properties</generateGitPropertiesFilename>
<generateGitPropertiesFilename>${project.basedir}/src/main/resources/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>
......
......@@ -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);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册