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

Method Run

cmd/tempo-cli/cmd-analyse-blocks.go:34–129  ·  view source on GitHub ↗
(ctx *globalOptions)

Source from the content-addressed store, hash-verified

32}
33
34func (cmd *analyseBlocksCmd) Run(ctx *globalOptions) error {
35 blobBytes, err := humanize.ParseBytes(cmd.BlobThreshold)
36 if err != nil {
37 return err
38 }
39
40 r, _, _, err := loadBackend(&cmd.backendOptions, ctx)
41 if err != nil {
42 return err
43 }
44
45 // TODO: Parallelize this
46 blocks, _, err := r.Blocks(context.Background(), cmd.TenantID)
47 if err != nil {
48 return err
49 }
50
51 var (
52 processedBlocks = map[uuid.UUID]struct{}{}
53 totalSummary blockSummary
54 maxStartTime, minStartTime time.Time
55 )
56
57 if cmd.MaxStartTime != "" {
58 maxStartTime, err = time.Parse(time.RFC3339, cmd.MaxStartTime)
59 if err != nil {
60 return err
61 }
62 }
63 if cmd.MinStartTime != "" {
64 minStartTime, err = time.Parse(time.RFC3339, cmd.MinStartTime)
65 if err != nil {
66 return err
67 }
68 }
69
70 if cmd.NumIntAttr == 0 {
71 cmd.NumIntAttr = cmd.NumAttr
72 }
73
74 if cmd.StrPercentThreshold <= 0 || cmd.StrPercentThreshold >= 1 {
75 return errors.New("str percent threshold must be between 0 and 1")
76 }
77
78 if cmd.IntPercentThreshold <= 0 || cmd.IntPercentThreshold >= 1 {
79 return errors.New("int percent threshold must be between 0 and 1")
80 }
81
82 settings := heuristicSettings{
83 NumStringAttr: cmd.NumAttr,
84 NumIntAttr: cmd.NumIntAttr,
85 BlobThresholdBytes: blobBytes,
86 StrThresholdPercent: cmd.StrPercentThreshold,
87 IntThresholdPercent: cmd.IntPercentThreshold,
88 }
89
90 printSettings := printSettings{
91 Simple: cmd.SimpleSummary,

Callers

nothing calls this directly

Calls 7

loadBackendFunction · 0.85
processBlockFunction · 0.85
printMethod · 0.80
BlocksMethod · 0.65
ParseMethod · 0.65
StringMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected