From 046db9ba907086a5358b5237961cbe1c6f560601 Mon Sep 17 00:00:00 2001 From: zhengziyi Date: Sat, 30 Nov 2024 12:23:08 +0800 Subject: [PATCH 1/3] fix: Replace timestamps with Duration in async profiler query --- go.mod | 2 +- go.sum | 4 +- .../profiling/asyncprofiler/getTaskList.go | 37 ++++++++----------- 3 files changed, 18 insertions(+), 25 deletions(-) diff --git a/go.mod b/go.mod index 4a771a30..e98246de 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( gopkg.in/yaml.v2 v2.4.0 k8s.io/apimachinery v0.22.1 sigs.k8s.io/controller-runtime v0.10.0 - skywalking.apache.org/repo/goapi v0.0.0-20241023080050-2514649a8007 + skywalking.apache.org/repo/goapi v0.0.0-20241129131257-944118bb91b8 ) require ( diff --git a/go.sum b/go.sum index 14f447f4..bf5055ab 100644 --- a/go.sum +++ b/go.sum @@ -879,5 +879,5 @@ sigs.k8s.io/structured-merge-diff/v4 v4.1.2 h1:Hr/htKFmJEbtMgS/UD0N+gtgctAqz81t3 sigs.k8s.io/structured-merge-diff/v4 v4.1.2/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4= sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= -skywalking.apache.org/repo/goapi v0.0.0-20241023080050-2514649a8007 h1:MQU9yOZxgbs7fU145wd400/E3ES/HWoxTtTCudaCBoA= -skywalking.apache.org/repo/goapi v0.0.0-20241023080050-2514649a8007/go.mod h1:+n8BMuS8eRdzdnGh15ElRGBXPi0eYZSs2TKySBDmRTE= +skywalking.apache.org/repo/goapi v0.0.0-20241129131257-944118bb91b8 h1:JkgizChUyT1mobFo2I3lI8+qsQU22i3FdxR0BSFC0uw= +skywalking.apache.org/repo/goapi v0.0.0-20241129131257-944118bb91b8/go.mod h1:+n8BMuS8eRdzdnGh15ElRGBXPi0eYZSs2TKySBDmRTE= diff --git a/internal/commands/profiling/asyncprofiler/getTaskList.go b/internal/commands/profiling/asyncprofiler/getTaskList.go index 067a3e2b..aba2a5bd 100644 --- a/internal/commands/profiling/asyncprofiler/getTaskList.go +++ b/internal/commands/profiling/asyncprofiler/getTaskList.go @@ -18,14 +18,14 @@ package asyncprofiler 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" + "github.com/urfave/cli/v2" + "skywalking.apache.org/repo/goapi/query" ) var getTaskListCommand = &cli.Command{ @@ -39,15 +39,8 @@ Examples: $ swctl profiling async list --service-name=service-name`, Flags: flags.Flags( flags.ServiceFlags, + flags.DurationFlags, []cli.Flag{ - &cli.Int64Flag{ - Name: "start-time", - Usage: "The start time (in milliseconds) of the event, measured between the current time and midnight, January 1, 1970 UTC.", - }, - &cli.Int64Flag{ - Name: "end-time", - Usage: "The end time (in milliseconds) of the event, measured between the current time and midnight, January 1, 1970 UTC.", - }, &cli.IntFlag{ Name: "limit", Usage: "Limit defines the number of the tasks to be returned.", @@ -56,16 +49,17 @@ $ swctl profiling async list --service-name=service-name`, ), Before: interceptor.BeforeChain( interceptor.ParseService(true), + interceptor.DurationInterceptor, ), Action: func(ctx *cli.Context) error { serviceID := ctx.String("service-id") - var startTime *int64 - if startTimeArg := ctx.Int64("start-time"); startTimeArg != 0 { - startTime = &startTimeArg - } - var endTime *int64 - if endTimeArg := ctx.Int64("end-time"); endTimeArg != 0 { - endTime = &endTimeArg + start := ctx.String("start") + end := ctx.String("end") + step := ctx.Generic("step") + duration := query.Duration{ + Start: start, + End: end, + Step: step.(*model.StepEnumValue).Selected, } var limit *int if limitArg := ctx.Int("limit"); limitArg != 0 { @@ -73,10 +67,9 @@ $ swctl profiling async list --service-name=service-name`, } request := &query.AsyncProfilerTaskListRequest{ - ServiceID: serviceID, - StartTime: startTime, - EndTime: endTime, - Limit: limit, + ServiceID: serviceID, + QueryDuration: &duration, + Limit: limit, } tasks, err := profiling.GetAsyncProfilerTaskList(ctx, request) From 3d8c962312b5c345b5e322c9766d7d2fe635be24 Mon Sep 17 00:00:00 2001 From: zhengziyi Date: Sat, 30 Nov 2024 12:43:57 +0800 Subject: [PATCH 2/3] fix: LICENSE --- dist/LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/LICENSE b/dist/LICENSE index 4bb722f2..1e90e05c 100644 --- a/dist/LICENSE +++ b/dist/LICENSE @@ -213,7 +213,7 @@ The text of each license is also included at licenses/license-[project].txt. k8s.io/utils v0.0.0-20210802155522-efc7438f0176 Apache-2.0 sigs.k8s.io/controller-runtime v0.10.0 Apache-2.0 sigs.k8s.io/structured-merge-diff/v4 v4.1.2 Apache-2.0 - skywalking.apache.org/repo/goapi v0.0.0-20241023080050-2514649a8007 Apache-2.0 + skywalking.apache.org/repo/goapi v0.0.0-20241129131257-944118bb91b8 Apache-2.0 ======================================================================== BSD-2-Clause licenses From 3554bc59fa5e35db88a1cf2c81c7e47f2cb83843 Mon Sep 17 00:00:00 2001 From: zhengziyi Date: Sat, 30 Nov 2024 13:09:05 +0800 Subject: [PATCH 3/3] fix: lint-ci --- internal/commands/profiling/asyncprofiler/getTaskList.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/commands/profiling/asyncprofiler/getTaskList.go b/internal/commands/profiling/asyncprofiler/getTaskList.go index aba2a5bd..554fac8f 100644 --- a/internal/commands/profiling/asyncprofiler/getTaskList.go +++ b/internal/commands/profiling/asyncprofiler/getTaskList.go @@ -18,14 +18,15 @@ package asyncprofiler 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" - "github.com/urfave/cli/v2" - "skywalking.apache.org/repo/goapi/query" ) var getTaskListCommand = &cli.Command{