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

Method Run

cmd/tempo-cli/cmd-suggest-columns.go:38–151  ·  view source on GitHub ↗
(ctx *globalOptions)

Source from the content-addressed store, hash-verified

36}
37
38func (cmd *suggestColumnsCmd) Run(ctx *globalOptions) error {
39 blobBytes, err := humanize.ParseBytes(cmd.BlobThreshold)
40 if err != nil {
41 return err
42 }
43
44 r, _, _, err := loadBackend(&cmd.backendOptions, ctx)
45 if err != nil {
46 return err
47 }
48
49 var (
50 processedBlocks = map[uuid.UUID]struct{}{}
51 totalSummary blockSummary
52 maxStartTime, minStartTime time.Time
53 )
54
55 if cmd.MaxStartTime != "" {
56 maxStartTime, err = time.Parse(time.RFC3339, cmd.MaxStartTime)
57 if err != nil {
58 return err
59 }
60 }
61 if cmd.MinStartTime != "" {
62 minStartTime, err = time.Parse(time.RFC3339, cmd.MinStartTime)
63 if err != nil {
64 return err
65 }
66 }
67
68 if cmd.NumIntAttr == 0 {
69 cmd.NumIntAttr = cmd.NumAttr
70 }
71
72 if cmd.StrPercentThreshold <= 0 || cmd.StrPercentThreshold >= 1 {
73 return errors.New("str percent threshold must be between 0 and 1")
74 }
75
76 if cmd.IntPercentThreshold <= 0 || cmd.IntPercentThreshold >= 1 {
77 return errors.New("int percent threshold must be between 0 and 1")
78 }
79
80 settings := heuristicSettings{
81 NumStringAttr: cmd.NumAttr,
82 NumIntAttr: cmd.NumIntAttr,
83 BlobThresholdBytes: blobBytes,
84 StrThresholdPercent: cmd.StrPercentThreshold,
85 IntThresholdPercent: cmd.IntPercentThreshold,
86 }
87
88 // if just one block
89 if cmd.BlockID != "" {
90 blockSum, err := processBlock(r, cmd.TenantID, cmd.BlockID, cmd.IncludeWellKnown, time.Time{}, time.Time{}, 0)
91 if err != nil {
92 if errors.Is(err, backend.ErrDoesNotExist) {
93 return errors.New("unable to analyze block: block has no block.meta because it was compacted")
94 }
95 return err

Callers

nothing calls this directly

Calls 8

loadBackendFunction · 0.85
processBlockFunction · 0.85
printDedicatedColumnsFunction · 0.85
ToDedicatedColumnsMethod · 0.80
ParseMethod · 0.65
BlocksMethod · 0.65
StringMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected