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 2022/05/18 11:38:26 UTC

[skywalking-cli] branch master updated: Remove `total` field in `trace list` and `logs list` commands (#152)

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-cli.git


The following commit(s) were added to refs/heads/master by this push:
     new 48238c6  Remove `total` field in `trace list` and `logs list` commands (#152)
48238c6 is described below

commit 48238c6d380df52b46bd6f67798ff572fb5723ed
Author: mrproliu <74...@qq.com>
AuthorDate: Wed May 18 19:38:22 2022 +0800

    Remove `total` field in `trace list` and `logs list` commands (#152)
---
 CHANGES.md                                |  1 +
 assets/graphqls/logs/Logs.graphql         |  1 -
 assets/graphqls/trace/Traces.graphql      |  1 -
 go.mod                                    |  2 +-
 go.sum                                    |  4 ++--
 internal/commands/alarm/list.go           |  6 ++----
 internal/commands/browser/logs/list.go    |  6 ++----
 internal/commands/event/list.go           |  6 ++----
 internal/commands/logs/list.go            |  6 ++----
 internal/commands/trace/list.go           |  6 ++----
 pkg/display/graph/tree/list.go            | 24 ++++++++----------------
 test/cases/8.8.1/expected/traces-list.yml |  1 -
 test/cases/9.0.0/expected/traces-list.yml |  1 -
 13 files changed, 22 insertions(+), 43 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index 907c61d..d270f3d 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -14,6 +14,7 @@ Release Notes.
 - Update the `process list` to must be provided the instance and duration.(#144)
 - Remove `layer` field in the `instance` and `process` commands for 9.1.0 GraphQL query protocol's breaking changes (#149)
 - Remove `duration` flag in `profiling ebpf schedules`.(#150)
+- [Breaking Change] Remove `total` field in `trace list` and `logs list` commands.(#152)
 
 0.10.0
 ------------------
diff --git a/assets/graphqls/logs/Logs.graphql b/assets/graphqls/logs/Logs.graphql
index 75ea577..38108f1 100644
--- a/assets/graphqls/logs/Logs.graphql
+++ b/assets/graphqls/logs/Logs.graphql
@@ -17,7 +17,6 @@
 
 query ($condition: LogQueryCondition!) {
     result: queryLogs(condition: $condition) {
-        total
         logs {
             serviceName
             serviceId
diff --git a/assets/graphqls/trace/Traces.graphql b/assets/graphqls/trace/Traces.graphql
index ef91477..8702989 100644
--- a/assets/graphqls/trace/Traces.graphql
+++ b/assets/graphqls/trace/Traces.graphql
@@ -17,7 +17,6 @@
 
 query ($condition: TraceQueryCondition!){
     result: queryBasicTraces(condition: $condition){
-        total
         traces {
             segmentId
             endpointNames
diff --git a/go.mod b/go.mod
index 7ee642d..4da523b 100644
--- a/go.mod
+++ b/go.mod
@@ -24,5 +24,5 @@ require (
 	gopkg.in/yaml.v2 v2.4.0
 	k8s.io/apimachinery v0.21.1
 	sigs.k8s.io/controller-runtime v0.7.0
-	skywalking.apache.org/repo/goapi v0.0.0-20220510085451-6911e2f4c612
+	skywalking.apache.org/repo/goapi v0.0.0-20220518085432-c95731d312d2
 )
diff --git a/go.sum b/go.sum
index 1861579..299a318 100644
--- a/go.sum
+++ b/go.sum
@@ -950,5 +950,5 @@ sigs.k8s.io/structured-merge-diff/v4 v4.1.0/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK
 sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
 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-20220510085451-6911e2f4c612 h1:nj/UGfpda0FbFJNoRDQYwuXEdlUJWPJFNxxKJyHcync=
-skywalking.apache.org/repo/goapi v0.0.0-20220510085451-6911e2f4c612/go.mod h1:uWwwvhcwe2MD/nJCg0c1EE/eL6KzaBosLHDfMFoEJ30=
+skywalking.apache.org/repo/goapi v0.0.0-20220518085432-c95731d312d2 h1:ejZ7/AVl5/hQn9WEsNSJm1OU/nI6YZwmTVEosW9Ij7U=
+skywalking.apache.org/repo/goapi v0.0.0-20220518085432-c95731d312d2/go.mod h1:uWwwvhcwe2MD/nJCg0c1EE/eL6KzaBosLHDfMFoEJ30=
diff --git a/internal/commands/alarm/list.go b/internal/commands/alarm/list.go
index 0419db2..7137bff 100644
--- a/internal/commands/alarm/list.go
+++ b/internal/commands/alarm/list.go
@@ -100,11 +100,9 @@ $ swctl alarm list
 		}
 
 		pageNum := 1
-		needTotal := true
 		paging := api.Pagination{
-			PageNum:   &pageNum,
-			PageSize:  DefaultPageSize,
-			NeedTotal: &needTotal,
+			PageNum:  &pageNum,
+			PageSize: DefaultPageSize,
 		}
 
 		condition := &alarm.ListAlarmCondition{
diff --git a/internal/commands/browser/logs/list.go b/internal/commands/browser/logs/list.go
index 5ffd737..c1adbce 100644
--- a/internal/commands/browser/logs/list.go
+++ b/internal/commands/browser/logs/list.go
@@ -67,12 +67,10 @@ $ swctl browser logs list`,
 		pageID := ctx.String("page-id")
 
 		pageNum := 1
-		needTotal := true
 
 		paging := api.Pagination{
-			PageNum:   &pageNum,
-			PageSize:  DefaultPageSize,
-			NeedTotal: &needTotal,
+			PageNum:  &pageNum,
+			PageSize: DefaultPageSize,
 		}
 		condition := &api.BrowserErrorLogQueryCondition{
 			ServiceID:        &serviceID,
diff --git a/internal/commands/event/list.go b/internal/commands/event/list.go
index 4d4eb86..20efbc3 100644
--- a/internal/commands/event/list.go
+++ b/internal/commands/event/list.go
@@ -94,12 +94,10 @@ $ swctl event list
 		eventType := api.EventType(ctx.Generic("type").(*model.EventTypeEnumValue).String())
 		layer := strings.ToUpper(ctx.String("layer"))
 		pageNum := 1
-		needTotal := true
 
 		paging := api.Pagination{
-			PageNum:   &pageNum,
-			PageSize:  DefaultPageSize,
-			NeedTotal: &needTotal,
+			PageNum:  &pageNum,
+			PageSize: DefaultPageSize,
 		}
 		condition := &api.EventQueryCondition{
 			Source: &api.SourceInput{
diff --git a/internal/commands/logs/list.go b/internal/commands/logs/list.go
index 81e1b39..10a33fc 100644
--- a/internal/commands/logs/list.go
+++ b/internal/commands/logs/list.go
@@ -83,7 +83,6 @@ $ swctl logs list --trace-id 3d56f33f-bcd3-4e40-9e4f-5dc547998ef5`,
 		endpointID := ctx.String("endpoint-id")
 		traceID := ctx.String("trace-id")
 		pageNum := 1
-		needTotal := true
 
 		tagStr := ctx.String("tags")
 		var tags []*api.LogTag = nil
@@ -96,9 +95,8 @@ $ swctl logs list --trace-id 3d56f33f-bcd3-4e40-9e4f-5dc547998ef5`,
 		}
 
 		paging := api.Pagination{
-			PageNum:   &pageNum,
-			PageSize:  DefaultPageSize,
-			NeedTotal: &needTotal,
+			PageNum:  &pageNum,
+			PageSize: DefaultPageSize,
 		}
 
 		condition := &api.LogQueryCondition{
diff --git a/internal/commands/trace/list.go b/internal/commands/trace/list.go
index e6bcc0a..b480ee7 100644
--- a/internal/commands/trace/list.go
+++ b/internal/commands/trace/list.go
@@ -105,12 +105,10 @@ $ swctl trace ls --trace-id "321661b1-9a31-4e12-ad64-c8f6711f108d"
 			}
 		}
 		pageNum := 1
-		needTotal := true
 
 		paging := api.Pagination{
-			PageNum:   &pageNum,
-			PageSize:  DefaultPageSize,
-			NeedTotal: &needTotal,
+			PageNum:  &pageNum,
+			PageSize: DefaultPageSize,
 		}
 
 		var order api.QueryOrder
diff --git a/pkg/display/graph/tree/list.go b/pkg/display/graph/tree/list.go
index a5951b6..84e2060 100644
--- a/pkg/display/graph/tree/list.go
+++ b/pkg/display/graph/tree/list.go
@@ -91,13 +91,13 @@ func DisplayList(ctx *cli.Context, displayable *d.Displayable) error {
 }
 
 func draw(list *widgets.List, tree *widgets.Tree, detail, help *widgets.Paragraph, data api.TraceBrief,
-	ctx *cli.Context, condition *api.TraceQueryCondition) {
+	ctx *cli.Context, _ *api.TraceQueryCondition) {
 	x, y := ui.TerminalDimensions()
 
-	if data.Total != 0 {
+	if len(data.Traces) != 0 {
 		showIndex := list.SelectedRow
 		var traceID = data.Traces[showIndex].TraceIds[0]
-		list.Title = fmt.Sprintf("[ %d/%d  %s]", *condition.Paging.PageNum, totalPages(data.Total), traceID)
+		list.Title = fmt.Sprintf("[%s]", traceID)
 		nodes, serviceNames := getNodeData(ctx, traceID)
 		tree.Title = fmt.Sprintf("[%s]", strings.Join(serviceNames, "->"))
 		tree.SetNodes(nodes)
@@ -118,12 +118,6 @@ func draw(list *widgets.List, tree *widgets.Tree, detail, help *widgets.Paragrap
 	tree.ExpandAll()
 	ui.Render(list, tree, detail, help)
 }
-func totalPages(total int) int {
-	if total%DefaultPageSize == 0 {
-		return total / DefaultPageSize
-	}
-	return total/DefaultPageSize + 1
-}
 
 func listenTracesKeyboard(list *widgets.List, tree *widgets.Tree, data api.TraceBrief, ctx *cli.Context,
 	detail, help *widgets.Paragraph, condition *api.TraceQueryCondition) {
@@ -149,13 +143,11 @@ func listenTracesKeyboard(list *widgets.List, tree *widgets.Tree, data api.Trace
 			tree.SelectedRow = 0
 		case "<C-f>", "n":
 			pageNum := *condition.Paging.PageNum
-			if pageNum < totalPages(data.Total) {
-				pageNum++
-				condition.Paging.PageNum = &pageNum
-				data, err = trace.Traces(ctx, condition)
-				if err != nil {
-					logger.Log.Fatalln(err)
-				}
+			pageNum++
+			condition.Paging.PageNum = &pageNum
+			data, err = trace.Traces(ctx, condition)
+			if err != nil {
+				logger.Log.Fatalln(err)
 			}
 			tree.SelectedRow = 0
 		case "<Right>":
diff --git a/test/cases/8.8.1/expected/traces-list.yml b/test/cases/8.8.1/expected/traces-list.yml
index 5dca15d..3150040 100644
--- a/test/cases/8.8.1/expected/traces-list.yml
+++ b/test/cases/8.8.1/expected/traces-list.yml
@@ -24,4 +24,3 @@ traces:
   traceids:
     - {{ index .traceids 0 }}
   {{- end }}
-total: {{ gt .total 0 }}
diff --git a/test/cases/9.0.0/expected/traces-list.yml b/test/cases/9.0.0/expected/traces-list.yml
index 5dca15d..3150040 100644
--- a/test/cases/9.0.0/expected/traces-list.yml
+++ b/test/cases/9.0.0/expected/traces-list.yml
@@ -24,4 +24,3 @@ traces:
   traceids:
     - {{ index .traceids 0 }}
   {{- end }}
-total: {{ gt .total 0 }}