未验证 提交 9e66bee7 编写于 作者: Z Zhenxu 提交者: GitHub

Make metrics exporter still work even when storage layer failed (#7041)

上级 bd38ec49
...@@ -32,7 +32,7 @@ Release Notes. ...@@ -32,7 +32,7 @@ Release Notes.
* Introduce method interceptor API v2 * Introduce method interceptor API v2
* Fix ClassCast issue for RequestHolder/ResponseHolder. * Fix ClassCast issue for RequestHolder/ResponseHolder.
* fixed `jdk-threading-plugin` memory leak. * fixed `jdk-threading-plugin` memory leak.
* Optimize multiple field reflection opeartion in Fiegn plugin. * Optimize multiple field reflection operation in Feign plugin.
#### OAP-Backend #### OAP-Backend
* BugFix: filter invalid Envoy access logs whose socket address is empty. * BugFix: filter invalid Envoy access logs whose socket address is empty.
...@@ -57,6 +57,7 @@ Release Notes. ...@@ -57,6 +57,7 @@ Release Notes.
* Events can be configured as alarm source. * Events can be configured as alarm source.
* Make the number of core worker in meter converter thread pool configurable. * Make the number of core worker in meter converter thread pool configurable.
* Add HTTP implementation of logs reporting protocol. * Add HTTP implementation of logs reporting protocol.
* Make metrics exporter still work even when storage layer failed.
#### UI #### UI
* Add logo for kong plugin. * Add logo for kong plugin.
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
package org.apache.skywalking.oap.server.core.analysis.worker; package org.apache.skywalking.oap.server.core.analysis.worker;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
...@@ -209,16 +208,23 @@ public class MetricsPersistentWorker extends PersistenceWorker<Metrics> { ...@@ -209,16 +208,23 @@ public class MetricsPersistentWorker extends PersistenceWorker<Metrics> {
/** /**
* Load data from the storage, if {@link #enableDatabaseSession} == true, only load data when the id doesn't exist. * Load data from the storage, if {@link #enableDatabaseSession} == true, only load data when the id doesn't exist.
*/ */
private void loadFromStorage(List<Metrics> metrics) throws IOException { private void loadFromStorage(List<Metrics> metrics) {
if (!enableDatabaseSession) { try {
context.clear(); List<Metrics> noInCacheMetrics = metrics.stream()
} .filter(m -> !context.containsKey(m) || !enableDatabaseSession)
.collect(Collectors.toList());
if (noInCacheMetrics.isEmpty()) {
return;
}
List<Metrics> noInCacheMetrics = metrics.stream() final List<Metrics> dbMetrics = metricsDAO.multiGet(model, noInCacheMetrics);
.filter(m -> !context.containsKey(m)) if (!enableDatabaseSession) {
.collect(Collectors.toList()); // Clear the cache only after results from DB are returned successfully.
if (!noInCacheMetrics.isEmpty()) { context.clear();
metricsDAO.multiGet(model, noInCacheMetrics).forEach(m -> context.put(m, m)); }
dbMetrics.forEach(m -> context.put(m, m));
} catch (final Exception e) {
log.error("Failed to load metrics for merging", e);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册