You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2021/10/22 00:20:32 UTC
[skywalking] branch master updated: Add `getProfileTaskLogs` query
method implement (#7984)
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking.git
The following commit(s) were added to refs/heads/master by this push:
new 8d24ba2 Add `getProfileTaskLogs` query method implement (#7984)
8d24ba2 is described below
commit 8d24ba2d9f76b0588a122a057ff0e8b7051d6635
Author: mrproliu <74...@qq.com>
AuthorDate: Fri Oct 22 08:20:10 2021 +0800
Add `getProfileTaskLogs` query method implement (#7984)
---
CHANGES.md | 1 +
.../server/core/query/ProfileTaskQueryService.java | 34 +++++++++++++++++-----
.../oap/query/graphql/resolver/ProfileQuery.java | 5 ++++
.../src/main/resources/query-protocol | 2 +-
.../profile/expected/profile-logs-finished.yml} | 20 ++++++++-----
test/e2e-v2/cases/profile/profile-cases.yaml | 6 ++++
test/e2e-v2/script/env | 2 +-
7 files changed, 53 insertions(+), 17 deletions(-)
diff --git a/CHANGES.md b/CHANGES.md
index dac41f6..6a3e1e9 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -47,6 +47,7 @@ Release Notes.
* Support `-Inf` as bucket in the meter system.
* Fix setting wrong field when combining `Event`s.
* Support search browser service.
+* Add `getProfileTaskLogs` to profile query protocol.
#### UI
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/ProfileTaskQueryService.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/ProfileTaskQueryService.java
index 5f272aa..9a65479 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/ProfileTaskQueryService.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/ProfileTaskQueryService.java
@@ -141,13 +141,7 @@ public class ProfileTaskQueryService implements Service {
task.setServiceName(serviceIDDefinition.getName());
// filter all task logs
- task.setLogs(taskLogList.stream().filter(l -> Objects.equal(l.getTaskId(), task.getId())).map(l -> {
- // get instance name from cache
- final IDManager.ServiceInstanceID.InstanceIDDefinition instanceIDDefinition = IDManager.ServiceInstanceID
- .analysisId(l.getInstanceId());
- l.setInstanceName(instanceIDDefinition.getName());
- return l;
- }).collect(Collectors.toList()));
+ task.setLogs(findMatchedLogs(task.getId(), taskLogList));
}
}
@@ -155,6 +149,19 @@ public class ProfileTaskQueryService implements Service {
}
/**
+ * query all task logs
+ */
+ public List<ProfileTaskLog> getProfileTaskLogs(final String taskID) throws IOException {
+ // query all and filter on task to match logs
+ List<ProfileTaskLog> taskLogList = getProfileTaskLogQueryDAO().getTaskLogList();
+ if (CollectionUtils.isEmpty(taskLogList)) {
+ return Collections.emptyList();
+ }
+
+ return findMatchedLogs(taskID, taskLogList);
+ }
+
+ /**
* search profiled traces
*/
public List<BasicTrace> getTaskTraces(String taskId) throws IOException {
@@ -229,4 +236,17 @@ public class ProfileTaskQueryService implements Service {
return spans;
}
+ private List<ProfileTaskLog> findMatchedLogs(final String taskID, final List<ProfileTaskLog> allLogs) {
+ return allLogs.stream()
+ .filter(l -> Objects.equal(l.getTaskId(), taskID))
+ .map(this::extendTaskLog)
+ .collect(Collectors.toList());
+ }
+
+ private ProfileTaskLog extendTaskLog(ProfileTaskLog log) {
+ final IDManager.ServiceInstanceID.InstanceIDDefinition instanceIDDefinition = IDManager.ServiceInstanceID
+ .analysisId(log.getInstanceId());
+ log.setInstanceName(instanceIDDefinition.getName());
+ return log;
+ }
}
diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/ProfileQuery.java b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/ProfileQuery.java
index 2edcd1c..431d00b 100644
--- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/ProfileQuery.java
+++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/ProfileQuery.java
@@ -25,6 +25,7 @@ import org.apache.skywalking.oap.server.core.query.type.BasicTrace;
import org.apache.skywalking.oap.server.core.query.type.ProfileAnalyzation;
import org.apache.skywalking.oap.server.core.query.type.ProfileAnalyzeTimeRange;
import org.apache.skywalking.oap.server.core.query.type.ProfileTask;
+import org.apache.skywalking.oap.server.core.query.type.ProfileTaskLog;
import org.apache.skywalking.oap.server.core.query.type.ProfiledSegment;
import org.apache.skywalking.oap.server.library.module.ModuleManager;
@@ -56,6 +57,10 @@ public class ProfileQuery implements GraphQLQueryResolver {
return getProfileTaskQueryService().getTaskList(serviceId, endpointName);
}
+ public List<ProfileTaskLog> getProfileTaskLogs(final String taskID) throws IOException {
+ return getProfileTaskQueryService().getProfileTaskLogs(taskID);
+ }
+
public List<BasicTrace> getProfileTaskSegmentList(final String taskID) throws IOException {
return getProfileTaskQueryService().getTaskTraces(taskID);
}
diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol b/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol
index 2d1b72b..38232af 160000
--- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol
+++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol
@@ -1 +1 @@
-Subproject commit 2d1b72baab57126e0341e2984e2beb95b39cb385
+Subproject commit 38232af334645cc321acc3cf02b186a0b241eb48
diff --git a/test/e2e-v2/script/env b/test/e2e-v2/cases/profile/expected/profile-logs-finished.yml
similarity index 63%
copy from test/e2e-v2/script/env
copy to test/e2e-v2/cases/profile/expected/profile-logs-finished.yml
index 3f33578..5838b2d 100644
--- a/test/e2e-v2/script/env
+++ b/test/e2e-v2/cases/profile/expected/profile-logs-finished.yml
@@ -13,11 +13,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-SW_AGENT_JAVA_COMMIT=3997f0256056788bd054ee37e4603c11c0fd6756
-SW_AGENT_SATELLITE_COMMIT=1f3c08a5af19f8522f2a40d9339c45fa816bfe07
-SW_AGENT_NGINX_LUA_COMMIT=c3cee4841798a147d83b96a10914d4ac0e11d0aa
-SW_AGENT_NODEJS_COMMIT=e755659c7f308d3b5589619778c8360308cb14f8
-SW_AGENT_GO_COMMIT=4af380c2db6243106b0fc650b6003ce3b3eb82a0
-SW_AGENT_PYTHON_COMMIT=50388c55428d742d73d9733278f04173585de80d
-
-SW_CTL_COMMIT=b90255132f916f53eb90955cc8a6445b03a4bec3
+{{- contains . }}
+- id: {{ notEmpty .id }}
+ instanceid: {{ b64enc "e2e-service-provider" }}.1_{{ b64enc "provider1" }}
+ operationtype: NOTIFIED
+ instancename: provider1
+ operationtime: {{ gt .operationtime 0 }}
+- id: {{ notEmpty .id }}
+ instanceid: {{ b64enc "e2e-service-provider" }}.1_{{ b64enc "provider1" }}
+ operationtype: EXECUTION_FINISHED
+ instancename: provider1
+ operationtime: {{ gt .operationtime 0 }}
+{{- end }}
\ No newline at end of file
diff --git a/test/e2e-v2/cases/profile/profile-cases.yaml b/test/e2e-v2/cases/profile/profile-cases.yaml
index 7c27b58..7f124e5 100644
--- a/test/e2e-v2/cases/profile/profile-cases.yaml
+++ b/test/e2e-v2/cases/profile/profile-cases.yaml
@@ -49,6 +49,12 @@
sleep 10;
swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql profile list -service-name=e2e-service-provider --endpoint-name=POST:/profile/{name}
expected: expected/profile-list-finished.yml
+ # profile logs
+ - query: |
+ swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql profile logs --task-id=$( \
+ swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql profile list --service-name=e2e-service-provider --endpoint-name=POST:/profile/{name} | yq e '.[0].id' - \
+ )
+ expected: expected/profile-logs-finished.yml
# profiled segment list
- query: |
swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql profile segment-list --task-id=$( \
diff --git a/test/e2e-v2/script/env b/test/e2e-v2/script/env
index 3f33578..ceef242 100644
--- a/test/e2e-v2/script/env
+++ b/test/e2e-v2/script/env
@@ -20,4 +20,4 @@ SW_AGENT_NODEJS_COMMIT=e755659c7f308d3b5589619778c8360308cb14f8
SW_AGENT_GO_COMMIT=4af380c2db6243106b0fc650b6003ce3b3eb82a0
SW_AGENT_PYTHON_COMMIT=50388c55428d742d73d9733278f04173585de80d
-SW_CTL_COMMIT=b90255132f916f53eb90955cc8a6445b03a4bec3
+SW_CTL_COMMIT=7dfb10bf79f463f16037e1ac352a8b2f5da6f27e