You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2022/05/07 09:33:42 UTC

[GitHub] [skywalking] wu-sheng commented on a diff in pull request #9003: Enhance Deprecated MetricQuery(v1) getValues querying

wu-sheng commented on code in PR #9003:
URL: https://github.com/apache/skywalking/pull/9003#discussion_r867330694


##########
oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/MetricQuery.java:
##########
@@ -59,17 +64,28 @@ public IntValues getValues(final BatchMetricConditions metrics, final Duration d
             kv.setValue(query.readMetricsValue(condition, duration));
             values.addKVInt(kv);
         } else {
-            for (final String id : metrics.getIds()) {
-                KVInt kv = new KVInt();
-                kv.setId(id);
+            List<CompletableFuture> futureList = new ArrayList<>();
+            metrics.getIds().stream().forEach(id -> {
 
                 MetricsCondition condition = new MetricsCondition();
                 condition.setName(metrics.getName());
                 condition.setEntity(new MockEntity(id));
-
-                kv.setValue(query.readMetricsValue(condition, duration));
-                values.addKVInt(kv);
-            }
+                CompletableFuture future = CompletableFuture.supplyAsync(() -> {
+                    try {
+                        return query.readMetricsValue(condition, duration);
+                    } catch (IOException e) {
+                        log.error("query.readMetricsValue error", e);
+                    }
+                    return 0L;
+                }).thenAccept(value -> {
+                    KVInt kv = new KVInt();
+                    kv.setId(id);
+                    kv.setValue(value);
+                    values.addKVInt(kv);

Review Comment:
   I think adding `Collections.synchronizedList` wrapper should be enough.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org