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 2021/08/18 06:25:09 UTC

[GitHub] [skywalking] wu-sheng commented on a change in pull request #7475: Add a new API to test log analysis language

wu-sheng commented on a change in pull request #7475:
URL: https://github.com/apache/skywalking/pull/7475#discussion_r690935826



##########
File path: oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/LogTestQuery.java
##########
@@ -0,0 +1,128 @@
+/*
+ * 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.resolver;
+
+import com.coxautodev.graphql.tools.GraphQLQueryResolver;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.stream.Collectors;
+import lombok.RequiredArgsConstructor;
+import org.apache.skywalking.apm.network.logging.v3.LogData;
+import org.apache.skywalking.oap.log.analyzer.dsl.Binding;
+import org.apache.skywalking.oap.log.analyzer.dsl.DSL;
+import org.apache.skywalking.oap.log.analyzer.module.LogAnalyzerModule;
+import org.apache.skywalking.oap.log.analyzer.provider.LogAnalyzerModuleConfig;
+import org.apache.skywalking.oap.log.analyzer.provider.LogAnalyzerModuleProvider;
+import org.apache.skywalking.oap.query.graphql.GraphQLQueryConfig;
+import org.apache.skywalking.oap.query.graphql.type.LogTestRequest;
+import org.apache.skywalking.oap.query.graphql.type.LogTestResponse;
+import org.apache.skywalking.oap.query.graphql.type.Metrics;
+import org.apache.skywalking.oap.server.core.analysis.IDManager;
+import org.apache.skywalking.oap.server.core.query.type.KeyValue;
+import org.apache.skywalking.oap.server.core.query.type.Log;
+import org.apache.skywalking.oap.server.library.module.ModuleManager;
+import org.apache.skywalking.oap.server.library.util.ProtoBufJsonUtils;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+import static org.apache.skywalking.apm.util.StringUtil.isNotBlank;
+
+@RequiredArgsConstructor
+public class LogTestQuery implements GraphQLQueryResolver {
+    private final ModuleManager moduleManager;
+
+    private final GraphQLQueryConfig config;
+
+    public LogTestResponse test(LogTestRequest request) throws Exception {
+        if (!config.isEnableLogTestTool()) {
+            throw new IllegalAccessException("LAL debug tool is not enabled");
+        }
+
+        requireNonNull(request, "request");
+        checkArgument(isNotBlank(request.getLog()), "request.log cannot be blank");
+        checkArgument(isNotBlank(request.getDsl()), "request.dsl cannot be blank");

Review comment:
       @Fine0830 When resolving response, please check `errors` in the response JSON.
   
   https://github.com/apache/skywalking/blob/6bb4d35ce80833661d688aa8d4ba4d02e60a5ebc/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/GraphQLQueryHandler.java#L97-L106
   
   Provide some notifications or tips to show error.




-- 
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