MCPcopy
hub / github.com/grafana/tempo / displayResults

Function displayResults

cmd/tempo-cli/cmd-list-blocks.go:37–116  ·  view source on GitHub ↗
(results []blockStats, windowDuration time.Duration, includeCompacted bool)

Source from the content-addressed store, hash-verified

35}
36
37func displayResults(results []blockStats, windowDuration time.Duration, includeCompacted bool) {
38 columns := []string{"id", "lvl", "objects", "size", "vers", "window", "start", "end", "duration", "age"}
39 if includeCompacted {
40 columns = append(columns, "cmp")
41 }
42
43 totalObjects := 0
44 totalBytes := uint64(0)
45
46 out := make([][]string, 0)
47 for _, r := range results {
48
49 line := make([]string, 0)
50
51 for _, c := range columns {
52 s := ""
53 switch c {
54 case "id":
55 s = r.BlockID.String()
56 case "lvl":
57 s = strconv.Itoa(int(r.CompactionLevel))
58 case "objects":
59 s = strconv.Itoa(int(r.TotalObjects))
60 case "size":
61 s = fmt.Sprintf("%v", humanize.Bytes(r.Size_))
62 case "vers":
63 s = r.Version
64 case "window":
65 // Display compaction window in human-readable format
66 window := time.Unix(r.window*int64(windowDuration.Seconds()), 0).UTC()
67 s = window.Format(time.RFC3339)
68 case "start":
69 s = r.StartTime.Format(time.RFC3339)
70 case "end":
71 s = r.EndTime.Format(time.RFC3339)
72 case "duration":
73 // Time range included in bucket
74 s = fmt.Sprint(r.EndTime.Sub(r.StartTime).Round(time.Second))
75 case "age":
76 s = fmt.Sprint(time.Since(r.EndTime).Round(time.Second))
77 case "cmp":
78 // Compacted?
79 if r.compacted {
80 s = "Y"
81 } else {
82 s = " "
83 }
84 }
85
86 line = append(line, s)
87 }
88
89 out = append(out, line)
90 totalObjects += int(r.TotalObjects)
91 totalBytes += r.Size_
92 }
93
94 footer := make([]string, 0)

Callers 1

RunMethod · 0.85

Calls 3

BytesMethod · 0.80
StringMethod · 0.45
HeaderMethod · 0.45

Tested by

no test coverage detected