support pprof cli feature (#226)
diff --git a/CHANGES.md b/CHANGES.md
index 4ae94b8..3af9896 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -15,6 +15,7 @@
* Add the `trace-v2 list` command for adapt the new trace query API by @mrproliu in https://github.com/apache/skywalking-cli/pull/225
* Add the duration field in the `trace list` command by @mrproliu in https://github.com/apache/skywalking-cli/pull/225
* Remove the oldest `queryTraceFromColdStage` query call in the `trace list` command by @mrproliu in https://github.com/apache/skywalking-cli/pull/225
+* Add the sub-command `profiling pprof` for pprof query API by @JophieQu in https://github.com/apache/skywalking-cli/pull/226
### Bug Fixes
diff --git a/assets/graphqls/profiling/pprof/CreateTask.graphql b/assets/graphqls/profiling/pprof/CreateTask.graphql
new file mode 100644
index 0000000..385e236
--- /dev/null
+++ b/assets/graphqls/profiling/pprof/CreateTask.graphql
@@ -0,0 +1,24 @@
+# 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.
+
+mutation ($condition: PprofTaskCreationRequest!) {
+ result: createPprofTask(pprofTaskCreationRequest: $condition) {
+ errorReason
+ code
+ id
+ }
+}
\ No newline at end of file
diff --git a/assets/graphqls/profiling/pprof/GetAnalysis.graphql b/assets/graphqls/profiling/pprof/GetAnalysis.graphql
new file mode 100644
index 0000000..3e7c590
--- /dev/null
+++ b/assets/graphqls/profiling/pprof/GetAnalysis.graphql
@@ -0,0 +1,30 @@
+# 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 ($condition: PprofAnalyzationRequest!) {
+ result: queryPprofAnalyze(request: $condition) {
+ tree {
+ elements {
+ id
+ parentId
+ codeSignature
+ total
+ self
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/assets/graphqls/profiling/pprof/GetTaskList.graphql b/assets/graphqls/profiling/pprof/GetTaskList.graphql
new file mode 100644
index 0000000..fc0ec70
--- /dev/null
+++ b/assets/graphqls/profiling/pprof/GetTaskList.graphql
@@ -0,0 +1,31 @@
+# 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 ($condition: PprofTaskListRequest!) {
+ result: queryPprofTaskList(request: $condition) {
+ errorReason
+ tasks {
+ serviceId
+ serviceInstanceIds
+ createTime
+ events
+ duration
+ dumpPeriod
+ id
+ }
+ }
+}
diff --git a/assets/graphqls/profiling/pprof/GetTaskProgress.graphql b/assets/graphqls/profiling/pprof/GetTaskProgress.graphql
new file mode 100644
index 0000000..0c74658
--- /dev/null
+++ b/assets/graphqls/profiling/pprof/GetTaskProgress.graphql
@@ -0,0 +1,30 @@
+# 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: queryPprofTaskProgress(taskId: $taskId) {
+ errorInstanceIds
+ successInstanceIds
+ logs {
+ id
+ instanceId
+ instanceName
+ operationType
+ operationTime
+ }
+ }
+}
\ No newline at end of file
diff --git a/dist/LICENSE b/dist/LICENSE
index e88d41e..fad46a8 100644
--- a/dist/LICENSE
+++ b/dist/LICENSE
@@ -213,7 +213,7 @@
sigs.k8s.io/controller-runtime v0.20.4 Apache-2.0
sigs.k8s.io/randfill v1.0.0 Apache-2.0
sigs.k8s.io/structured-merge-diff/v4 v4.7.0 Apache-2.0
- skywalking.apache.org/repo/goapi v0.0.0-20250918024206-7be91673cadc Apache-2.0
+ skywalking.apache.org/repo/goapi v0.0.0-20251011100214-efff910f2031 Apache-2.0
========================================================================
Apache-2.0 and BSD-3-Clause licenses
diff --git a/go.mod b/go.mod
index 6a22c66..4230fda 100644
--- a/go.mod
+++ b/go.mod
@@ -18,7 +18,7 @@
gopkg.in/yaml.v2 v2.4.0
k8s.io/apimachinery v0.33.1
sigs.k8s.io/controller-runtime v0.20.4
- skywalking.apache.org/repo/goapi v0.0.0-20250918024206-7be91673cadc
+ skywalking.apache.org/repo/goapi v0.0.0-20251011100214-efff910f2031
)
require (
diff --git a/go.sum b/go.sum
index 6587f3f..d664728 100644
--- a/go.sum
+++ b/go.sum
@@ -543,5 +543,5 @@
sigs.k8s.io/structured-merge-diff/v4 v4.7.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps=
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=
-skywalking.apache.org/repo/goapi v0.0.0-20250918024206-7be91673cadc h1:HhlLDl0aOIgiIdJl9p0a7PHHdZbs9epKEnewB7AWdZs=
-skywalking.apache.org/repo/goapi v0.0.0-20250918024206-7be91673cadc/go.mod h1:Vj9vINJYsTQASPsbQ1i81YgH8nFC/Xds4GjcXvmRYwM=
+skywalking.apache.org/repo/goapi v0.0.0-20251011100214-efff910f2031 h1:iMd6gzltWrWOtV3COm0mWydeXhpy7r1vkNlTsm7Co0g=
+skywalking.apache.org/repo/goapi v0.0.0-20251011100214-efff910f2031/go.mod h1:Vj9vINJYsTQASPsbQ1i81YgH8nFC/Xds4GjcXvmRYwM=
diff --git a/internal/commands/interceptor/instance.go b/internal/commands/interceptor/instance.go
index d381717..83ccfbb 100644
--- a/internal/commands/interceptor/instance.go
+++ b/internal/commands/interceptor/instance.go
@@ -106,6 +106,7 @@
if idsArg == "" && namesArgs == "" {
if required {
+ _ = cli.ShowSubcommandHelp(ctx)
return fmt.Errorf(`either flags "--%s" or "--%s" must be given`, idListFlagName, nameListFlagName)
}
return nil
diff --git a/internal/commands/interceptor/service.go b/internal/commands/interceptor/service.go
index d87e12a..183cc3b 100644
--- a/internal/commands/interceptor/service.go
+++ b/internal/commands/interceptor/service.go
@@ -74,6 +74,7 @@
if id == "" && name == "" {
if required {
+ _ = cli.ShowSubcommandHelp(ctx)
return fmt.Errorf(`either flags "--%s" or "--%s" must be given`, idFlagName, nameFlagName)
}
return nil
diff --git a/internal/commands/profiling/pprof/create.go b/internal/commands/profiling/pprof/create.go
new file mode 100644
index 0000000..618c4df
--- /dev/null
+++ b/internal/commands/profiling/pprof/create.go
@@ -0,0 +1,96 @@
+// 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 pprof
+
+import (
+ "strings"
+
+ "github.com/urfave/cli/v2"
+ "skywalking.apache.org/repo/goapi/query"
+
+ "github.com/apache/skywalking-cli/internal/commands/interceptor"
+ "github.com/apache/skywalking-cli/internal/flags"
+ "github.com/apache/skywalking-cli/internal/model/pprof"
+ "github.com/apache/skywalking-cli/pkg/display"
+ "github.com/apache/skywalking-cli/pkg/display/displayable"
+ "github.com/apache/skywalking-cli/pkg/graphql/profiling"
+)
+
+var createCommand = &cli.Command{
+ Name: "create",
+ Aliases: []string{"c"},
+ Usage: "Create a new pprof task",
+ UsageText: `Create a new pprof task
+
+Examples:
+1. Create pprof task
+$ swctl profiling pprof create --service-name=service-name --duration=10 --events=mutex \
+ --instance-name-list=instance-name1,instance-name2 --dump-period=1`,
+ Flags: flags.Flags(
+ flags.ServiceFlags,
+ flags.InstanceListFlags,
+ []cli.Flag{
+ &cli.IntFlag{
+ Name: "duration",
+ Usage: "task continuous time(minute), required for cpu, block and mutex events. ",
+ },
+ &cli.GenericFlag{
+ Name: "events",
+ Usage: "which event types this task needs to collect.",
+ Required: true,
+ Value: &pprof.ProfilingEventTypeEnumValue{
+ Enum: query.AllPprofEventType,
+ Default: query.PprofEventTypeCPU,
+ },
+ },
+ &cli.StringFlag{
+ Name: "dump-period",
+ Usage: "pprof dump period parameters, required for block and mutex events. ",
+ },
+ },
+ ),
+ Before: interceptor.BeforeChain(
+ interceptor.ParseService(true),
+ interceptor.ParseInstanceList(true),
+ ),
+ Action: func(ctx *cli.Context) error {
+ serviceID := ctx.String("service-id")
+ instanceIDs := strings.Split(ctx.String("instance-id-list"), ",")
+ eventTypes := ctx.Generic("events").(*pprof.ProfilingEventTypeEnumValue).Selected
+ var dumpPeriod, duration *int
+ if durationtime := ctx.Int("duration"); durationtime != 0 {
+ duration = &durationtime
+ }
+ if period := ctx.Int("dump-period"); period != 0 {
+ dumpPeriod = &period
+ }
+ request := &query.PprofTaskCreationRequest{
+ ServiceID: serviceID,
+ ServiceInstanceIds: instanceIDs,
+ Duration: duration,
+ Events: eventTypes,
+ DumpPeriod: dumpPeriod,
+ }
+ task, err := profiling.CreatePprofTask(ctx.Context, request)
+ if err != nil {
+ return err
+ }
+
+ return display.Display(ctx.Context, &displayable.Displayable{Data: task, Condition: request})
+ },
+}
diff --git a/internal/commands/profiling/pprof/getAnalyze.go b/internal/commands/profiling/pprof/getAnalyze.go
new file mode 100644
index 0000000..fe0dd09
--- /dev/null
+++ b/internal/commands/profiling/pprof/getAnalyze.go
@@ -0,0 +1,74 @@
+// 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 pprof
+
+import (
+ "strings"
+
+ "github.com/urfave/cli/v2"
+ "skywalking.apache.org/repo/goapi/query"
+
+ "github.com/apache/skywalking-cli/internal/commands/interceptor"
+ "github.com/apache/skywalking-cli/internal/flags"
+ "github.com/apache/skywalking-cli/pkg/display"
+ "github.com/apache/skywalking-cli/pkg/display/displayable"
+ "github.com/apache/skywalking-cli/pkg/graphql/profiling"
+)
+
+var analysisCommand = &cli.Command{
+ Name: "analysis",
+ Aliases: []string{"a"},
+ Usage: "Query pprof analysis",
+ UsageText: `Query pprof analysis
+
+Examples:
+1. Query the flame graph produced by pprof
+$ swctl profiling pprof analysis --service-name=service-name --task-id=task-id \
+ --instance-name-list=instance-name1,instance-name2`,
+ Flags: flags.Flags(
+ flags.ServiceFlags,
+ flags.InstanceListFlags,
+ []cli.Flag{
+ &cli.StringFlag{
+ Name: "task-id",
+ Usage: "pprof task id",
+ Required: true,
+ },
+ },
+ ),
+ Before: interceptor.BeforeChain(
+ interceptor.ParseService(true),
+ interceptor.ParseInstanceList(true),
+ ),
+ Action: func(ctx *cli.Context) error {
+ taskID := ctx.String("task-id")
+ instances := strings.Split(ctx.String("instance-id-list"), ",")
+
+ request := &query.PprofAnalyzationRequest{
+ TaskID: taskID,
+ InstanceIds: instances,
+ }
+
+ analyze, err := profiling.GetPprofAnalyze(ctx.Context, request)
+ if err != nil {
+ return err
+ }
+
+ return display.Display(ctx.Context, &displayable.Displayable{Data: analyze, Condition: request})
+ },
+}
diff --git a/internal/commands/profiling/pprof/getTaskList.go b/internal/commands/profiling/pprof/getTaskList.go
new file mode 100644
index 0000000..f6df79b
--- /dev/null
+++ b/internal/commands/profiling/pprof/getTaskList.go
@@ -0,0 +1,85 @@
+// 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 pprof
+
+import (
+ "github.com/urfave/cli/v2"
+ "skywalking.apache.org/repo/goapi/query"
+
+ "github.com/apache/skywalking-cli/internal/commands/interceptor"
+ "github.com/apache/skywalking-cli/internal/flags"
+ "github.com/apache/skywalking-cli/internal/model"
+ "github.com/apache/skywalking-cli/pkg/display"
+ "github.com/apache/skywalking-cli/pkg/display/displayable"
+ "github.com/apache/skywalking-cli/pkg/graphql/profiling"
+)
+
+var getTaskListCommand = &cli.Command{
+ Name: "list",
+ Aliases: []string{"l"},
+ Usage: "Query pprof task list",
+ UsageText: `Query pprof task list
+
+Examples:
+1. Query all pprof tasks
+$ swctl profiling pprof list --service-name=service-name`,
+ Flags: flags.Flags(
+ flags.ServiceFlags,
+ flags.DurationFlags,
+ []cli.Flag{
+ &cli.IntFlag{
+ Name: "limit",
+ Usage: "Limit defines the number of the tasks to be returned.",
+ },
+ },
+ ),
+ Before: interceptor.BeforeChain(
+ interceptor.ParseService(true),
+ interceptor.DurationInterceptor,
+ ),
+ Action: func(ctx *cli.Context) error {
+ serviceID := ctx.String("service-id")
+ start := ctx.String("start")
+ end := ctx.String("end")
+ step := ctx.Generic("step")
+ cold := ctx.Bool("cold")
+ duration := query.Duration{
+ Start: start,
+ End: end,
+ Step: step.(*model.StepEnumValue).Selected,
+ ColdStage: &cold,
+ }
+ var limit *int
+ if limitArg := ctx.Int("limit"); limitArg != 0 {
+ limit = &limitArg
+ }
+
+ request := &query.PprofTaskListRequest{
+ ServiceID: serviceID,
+ QueryDuration: &duration,
+ Limit: limit,
+ }
+
+ tasks, err := profiling.GetPprofTaskList(ctx.Context, request)
+ if err != nil {
+ return err
+ }
+
+ return display.Display(ctx.Context, &displayable.Displayable{Data: tasks, Condition: request})
+ },
+}
diff --git a/internal/commands/profiling/pprof/getTaskProgress.go b/internal/commands/profiling/pprof/getTaskProgress.go
new file mode 100644
index 0000000..f032590
--- /dev/null
+++ b/internal/commands/profiling/pprof/getTaskProgress.go
@@ -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 pprof
+
+import (
+ "github.com/urfave/cli/v2"
+
+ "github.com/apache/skywalking-cli/pkg/display"
+ "github.com/apache/skywalking-cli/pkg/display/displayable"
+ "github.com/apache/skywalking-cli/pkg/graphql/profiling"
+)
+
+var getTaskProgressCommand = &cli.Command{
+ Name: "progress",
+ Aliases: []string{"p"},
+ Flags: []cli.Flag{
+ &cli.StringFlag{
+ Name: "task-id",
+ Usage: "pprof task id.",
+ Required: true,
+ },
+ },
+ Usage: "Query pprof task progress",
+ UsageText: `Query pprof task progress
+
+Examples:
+1. Query task progress, including task logs and successInstances and errorInstances
+$ swctl profiling pprof progress --task-id=task-id`,
+ Action: func(ctx *cli.Context) error {
+ taskID := ctx.String("task-id")
+
+ data, err := profiling.GetPprofTaskProgress(ctx.Context, taskID)
+ if err != nil {
+ return err
+ }
+
+ return display.Display(ctx.Context, &displayable.Displayable{Data: data, Condition: taskID})
+ },
+}
diff --git a/internal/commands/profiling/pprof/pprof.go b/internal/commands/profiling/pprof/pprof.go
new file mode 100644
index 0000000..fdb4019
--- /dev/null
+++ b/internal/commands/profiling/pprof/pprof.go
@@ -0,0 +1,31 @@
+// 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 pprof
+
+import "github.com/urfave/cli/v2"
+
+var Command = &cli.Command{
+ Name: "pprof",
+ Usage: "pprof related sub-command",
+ Subcommands: []*cli.Command{
+ createCommand,
+ getTaskListCommand,
+ getTaskProgressCommand,
+ analysisCommand,
+ },
+}
diff --git a/internal/commands/profiling/profiling.go b/internal/commands/profiling/profiling.go
index 54144b6..bc2eab1 100644
--- a/internal/commands/profiling/profiling.go
+++ b/internal/commands/profiling/profiling.go
@@ -23,6 +23,7 @@
"github.com/apache/skywalking-cli/internal/commands/profiling/asyncprofiler"
"github.com/apache/skywalking-cli/internal/commands/profiling/continuous"
"github.com/apache/skywalking-cli/internal/commands/profiling/ebpf"
+ "github.com/apache/skywalking-cli/internal/commands/profiling/pprof"
"github.com/apache/skywalking-cli/internal/commands/profiling/trace"
)
@@ -36,5 +37,6 @@
ebpf.Command,
continuous.Command,
asyncprofiler.Command,
+ pprof.Command,
},
}
diff --git a/internal/model/pprof/pprofEventType.go b/internal/model/pprof/pprofEventType.go
new file mode 100644
index 0000000..08eeaf8
--- /dev/null
+++ b/internal/model/pprof/pprofEventType.go
@@ -0,0 +1,49 @@
+// 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 pprof
+
+import (
+ "fmt"
+ "strings"
+
+ api "skywalking.apache.org/repo/goapi/query"
+)
+
+type ProfilingEventTypeEnumValue struct {
+ Enum []api.PprofEventType
+ Default api.PprofEventType
+ Selected api.PprofEventType
+}
+
+func (e *ProfilingEventTypeEnumValue) Set(value string) error {
+ for _, enum := range e.Enum {
+ if strings.EqualFold(enum.String(), value) {
+ e.Selected = enum
+ return nil
+ }
+ }
+ orders := make([]string, len(api.AllPprofEventType))
+ for i, order := range api.AllPprofEventType {
+ orders[i] = order.String()
+ }
+ return fmt.Errorf("allowed analysis aggregate type are %s", strings.Join(orders, ", "))
+}
+
+func (e *ProfilingEventTypeEnumValue) String() string {
+ return e.Selected.String()
+}
diff --git a/pkg/graphql/profiling/pprof.go b/pkg/graphql/profiling/pprof.go
new file mode 100644
index 0000000..6f4a70b
--- /dev/null
+++ b/pkg/graphql/profiling/pprof.go
@@ -0,0 +1,72 @@
+// 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 profiling
+
+import (
+ "context"
+
+ "github.com/machinebox/graphql"
+ api "skywalking.apache.org/repo/goapi/query"
+
+ "github.com/apache/skywalking-cli/assets"
+ "github.com/apache/skywalking-cli/pkg/graphql/client"
+)
+
+func CreatePprofTask(ctx context.Context, condition *api.PprofTaskCreationRequest) (api.PprofTaskCreationResult, error) {
+ var response map[string]api.PprofTaskCreationResult
+
+ request := graphql.NewRequest(assets.Read("graphqls/profiling/pprof/CreateTask.graphql"))
+ request.Var("condition", condition)
+
+ err := client.ExecuteQuery(ctx, request, &response)
+
+ return response["result"], err
+}
+
+func GetPprofTaskProgress(ctx context.Context, taskID string) (api.PprofTaskProgress, error) {
+ var response map[string]api.PprofTaskProgress
+
+ request := graphql.NewRequest(assets.Read("graphqls/profiling/pprof/GetTaskProgress.graphql"))
+ request.Var("taskId", taskID)
+
+ err := client.ExecuteQuery(ctx, request, &response)
+
+ return response["result"], err
+}
+
+func GetPprofTaskList(ctx context.Context, condition *api.PprofTaskListRequest) (api.PprofTaskListResult, error) {
+ var response map[string]api.PprofTaskListResult
+
+ request := graphql.NewRequest(assets.Read("graphqls/profiling/pprof/GetTaskList.graphql"))
+ request.Var("condition", condition)
+
+ err := client.ExecuteQuery(ctx, request, &response)
+
+ return response["result"], err
+}
+
+func GetPprofAnalyze(ctx context.Context, condition *api.PprofAnalyzationRequest) (api.PprofAnalyzation, error) {
+ var response map[string]api.PprofAnalyzation
+
+ request := graphql.NewRequest(assets.Read("graphqls/profiling/pprof/GetAnalysis.graphql"))
+ request.Var("condition", condition)
+
+ err := client.ExecuteQuery(ctx, request, &response)
+
+ return response["result"], err
+}