Add `getProfileTaskLogs` query method implement (#7984)

This commit is contained in:
mrproliu 2021-10-22 08:20:10 +08:00 committed by GitHub
parent 7a5fec56fe
commit 8d24ba2d9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 68 additions and 9 deletions

View File

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

View File

@ -141,19 +141,26 @@ 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));
}
}
return tasks;
}
/**
* 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
*/
@ -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;
}
}

View File

@ -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);
}

@ -1 +1 @@
Subproject commit 2d1b72baab57126e0341e2984e2beb95b39cb385
Subproject commit 38232af334645cc321acc3cf02b186a0b241eb48

View File

@ -0,0 +1,27 @@
# 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.
{{- 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 }}

View File

@ -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=$( \

View File

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