You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by "wankai123 (via GitHub)" <gi...@apache.org> on 2024/08/13 02:05:15 UTC
[PR] Support async query for the composite GraphQL query. [skywalking]
wankai123 opened a new pull request, #12525:
URL: https://github.com/apache/skywalking/pull/12525
relate to https://github.com/apache/skywalking/issues/12416
- [ ] If this pull request closes/resolves/fixes an existing issue, replace the issue number. Closes #<issue number>.
- [X] Update the [`CHANGES` log](https://github.com/apache/skywalking/blob/master/docs/en/changes/changes.md).
--
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
Re: [PR] Support async query for the composite GraphQL query. [skywalking]
Posted by "wankai123 (via GitHub)" <gi...@apache.org>.
wankai123 commented on code in PR #12525:
URL: https://github.com/apache/skywalking/pull/12525#discussion_r1714726648
##########
oap-server/server-query-plugin/debugging-query-plugin/src/main/java/org/apache/skywalking/oap/query/debug/DebuggingHTTPHandler.java:
##########
@@ -160,8 +160,8 @@ public String execExpression(@Param("dumpDBRsp") boolean dumpStorageRsp,
@SneakyThrows
@Get("/debugging/query/trace/queryBasicTraces")
- public String queryBasicTraces(@Param("service") String service,
- @Param("serviceLayer") String serviceLayer,
+ public String queryBasicTraces(@Param("service") Optional<String> service,
Review Comment:
The `serviceId/serviceInstanceId/endpointId` in the graphQL are optional, the implement also can ignore them.
https://github.com/apache/skywalking-query-protocol/blob/6ed9a1bb96c1c753d3211e55995117c9617e4339/trace.graphqls#L37
--
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
Re: [PR] Support async query for the composite GraphQL query. [skywalking]
Posted by "kezhenxu94 (via GitHub)" <gi...@apache.org>.
kezhenxu94 commented on code in PR #12525:
URL: https://github.com/apache/skywalking/pull/12525#discussion_r1714712346
##########
oap-server/server-query-plugin/debugging-query-plugin/src/main/java/org/apache/skywalking/oap/query/debug/DebuggingHTTPHandler.java:
##########
@@ -176,10 +176,11 @@ public String queryBasicTraces(@Param("service") String service,
@Param("pageNum") int pageNum,
@Param("pageSize") int pageSize
) {
- String serviceId = IDManager.ServiceID.buildId(service, Layer.nameOf(serviceLayer).isNormal());
+ Optional<String> serviceId = service.map(
Review Comment:
Why change to `Optional<String> serviceLayer` and `serviceLayer.orElseThrow()` if it’s required?
--
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
Re: [PR] Support async query for the composite GraphQL query. [skywalking]
Posted by "kezhenxu94 (via GitHub)" <gi...@apache.org>.
kezhenxu94 commented on code in PR #12525:
URL: https://github.com/apache/skywalking/pull/12525#discussion_r1714725324
##########
oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/AsyncQuery.java:
##########
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.query.graphql;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ForkJoinPool;
+import java.util.function.Supplier;
+
+import static java.util.concurrent.ForkJoinPool.defaultForkJoinWorkerThreadFactory;
+
+public abstract class AsyncQuery {
+ private static final Executor EXECUTOR = new ForkJoinPool(
+ Runtime.getRuntime().availableProcessors(), defaultForkJoinWorkerThreadFactory, null, true);
+
+ protected static <U> CompletableFuture<U> queryAsync(Supplier<U> supplier) {
+ return CompletableFuture.supplyAsync(supplier, EXECUTOR);
+ }
Review Comment:
Also I think this class can be a utility class so that we don’t need to mess up the class hierarchy in all query resolvers
--
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
Re: [PR] Support async query for the composite GraphQL query. [skywalking]
Posted by "kezhenxu94 (via GitHub)" <gi...@apache.org>.
kezhenxu94 commented on code in PR #12525:
URL: https://github.com/apache/skywalking/pull/12525#discussion_r1714713940
##########
oap-server/server-query-plugin/debugging-query-plugin/src/main/java/org/apache/skywalking/oap/query/debug/DebuggingHTTPHandler.java:
##########
@@ -160,8 +160,8 @@ public String execExpression(@Param("dumpDBRsp") boolean dumpStorageRsp,
@SneakyThrows
@Get("/debugging/query/trace/queryBasicTraces")
- public String queryBasicTraces(@Param("service") String service,
- @Param("serviceLayer") String serviceLayer,
+ public String queryBasicTraces(@Param("service") Optional<String> service,
Review Comment:
Based on the implementation I think `service` and `serviceLayer` are required and should not be `Optional`
--
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
Re: [PR] Support async query for the composite GraphQL query. [skywalking]
Posted by "kezhenxu94 (via GitHub)" <gi...@apache.org>.
kezhenxu94 commented on code in PR #12525:
URL: https://github.com/apache/skywalking/pull/12525#discussion_r1714724054
##########
oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/AsyncQuery.java:
##########
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.query.graphql;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ForkJoinPool;
+import java.util.function.Supplier;
+
+import static java.util.concurrent.ForkJoinPool.defaultForkJoinWorkerThreadFactory;
+
+public abstract class AsyncQuery {
+ private static final Executor EXECUTOR = new ForkJoinPool(
+ Runtime.getRuntime().availableProcessors(), defaultForkJoinWorkerThreadFactory, null, true);
+
+ protected static <U> CompletableFuture<U> queryAsync(Supplier<U> supplier) {
+ return CompletableFuture.supplyAsync(supplier, EXECUTOR);
+ }
Review Comment:
Consider wrapping the `supplier` with `callable` so that we don’t have to `try-catch` in all implementations
```suggestion
protected static <U> CompletableFuture<U> queryAsync(Callable<U> caller) {
return CompletableFuture.supplyAsync(() -> {
try {
return caller.call();
} catch (Exception e) {
throw new RuntimeException(e);
}
}, EXECUTOR);
}
```
--
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
Re: [PR] Support async query for the composite GraphQL query. [skywalking]
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng merged PR #12525:
URL: https://github.com/apache/skywalking/pull/12525
--
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