Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions assets/graphqls/profile/GetProfileTaskLogs.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Licensed to 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. Apache Software Foundation (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.

query ($taskID: String) {
result: getProfileTaskLogs(taskID: $taskID) {
id
instanceId
instanceName
operationType
operationTime
}
}
54 changes: 54 additions & 0 deletions internal/commands/profile/getTaskLogs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Licensed to 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. Apache Software Foundation (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 profile

import (
"github.com/apache/skywalking-cli/pkg/display"
"github.com/apache/skywalking-cli/pkg/display/displayable"
"github.com/apache/skywalking-cli/pkg/graphql/profile"

"github.com/urfave/cli/v2"
)

var getTaskLogListCommand = &cli.Command{
Name: "logs",
Aliases: []string{"logs"},
Flags: []cli.Flag{
&cli.StringFlag{
Name: "task-id",
Usage: "profile task id.",
},
},
Usage: "Query profile task log list",
UsageText: `Query profile task log list

Examples:
1. Query all profile logs of task id "task-id"
$ swctl profile logs --task-id=task-id`,
Action: func(ctx *cli.Context) error {
taskID := ctx.String("task-id")

task, err := profile.GetTaskLogList(ctx, taskID)

if err != nil {
return err
}

return display.Display(ctx, &displayable.Displayable{Data: task, Condition: taskID})
},
}
1 change: 1 addition & 0 deletions internal/commands/profile/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ on https://github.com/apache/skywalking/blob/master/docs/en/guides/backend-profi
Subcommands: []*cli.Command{
createCommand,
getTaskListCommand,
getTaskLogListCommand,
getTaskSegmentListCommand,
getProfiledSegmentCommand,
getProfiledAnalyzeCommand,
Expand Down
11 changes: 11 additions & 0 deletions pkg/graphql/profile/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ func GetTaskList(ctx *cli.Context, serviceID, endpointName string) ([]*api.Profi
return response["result"], err
}

func GetTaskLogList(ctx *cli.Context, taskID string) ([]*api.ProfileTaskLog, error) {
var response map[string][]*api.ProfileTaskLog

request := graphql.NewRequest(assets.Read("graphqls/profile/GetProfileTaskLogs.graphql"))
request.Var("taskID", taskID)

err := client.ExecuteQuery(ctx, request, &response)

return response["result"], err
}

func GetTaskSegmentList(ctx *cli.Context, taskID string) ([]*api.BasicTrace, error) {
var response map[string][]*api.BasicTrace

Expand Down