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

Function printCliArgs

cmd/tempo-cli/cmd-analyse-block.go:993–1032  ·  view source on GitHub ↗
(s blockSummary, settings heuristicSettings, numRowGroups int)

Source from the content-addressed store, hash-verified

991}
992
993func printCliArgs(s blockSummary, settings heuristicSettings, numRowGroups int) {
994 fmt.Println("")
995 fmt.Printf("quoted/spaced cli list:")
996
997 escapeString := func(s string) string {
998 return strings.ReplaceAll(s, "\"", "\\\"")
999 }
1000
1001 doStringSummary := func(summary attributeSummary, scope traceql.AttributeScope) {
1002 for _, a := range topN(settings.NumStringAttr, summary.attributes) {
1003 if float64(a.cardinality.totalOccurrences())/float64(summary.rowCount) < settings.StrThresholdPercent {
1004 // Did not meet threshold
1005 continue
1006 }
1007 attrStr := traceql.NewScopedAttribute(scope, false, a.name).String()
1008 if settings.BlobThresholdBytes > 0 && a.cardinality.avgSizePerRowGroup(numRowGroups) > settings.BlobThresholdBytes {
1009 attrStr = "blob/" + attrStr
1010 }
1011 fmt.Printf("\"%s\" ", escapeString(attrStr))
1012 }
1013 }
1014
1015 doIntSummary := func(summary attributeSummary, scope traceql.AttributeScope) {
1016 for _, a := range topNInt(settings.NumIntAttr, summary.integerAttributes) {
1017 if float64(a.count)/float64(summary.rowCount) < settings.IntThresholdPercent {
1018 continue
1019 }
1020 attrStr := traceql.NewScopedAttribute(scope, false, a.name).String()
1021 fmt.Printf("\"%s\" ", escapeString(attrStr))
1022 }
1023 }
1024
1025 doStringSummary(s.spanSummary, traceql.AttributeScopeSpan)
1026 doStringSummary(s.resourceSummary, traceql.AttributeScopeResource)
1027 doStringSummary(s.eventSummary, traceql.AttributeScopeEvent)
1028
1029 doIntSummary(s.spanSummary, traceql.AttributeScopeSpan)
1030 doIntSummary(s.resourceSummary, traceql.AttributeScopeResource)
1031 doIntSummary(s.eventSummary, traceql.AttributeScopeEvent)
1032}
1033
1034func topN(n int, attrs map[string]*stringAttributeSummary) []*stringAttributeSummary {
1035 top := make([]*stringAttributeSummary, 0, len(attrs))

Callers 1

printMethod · 0.85

Calls 6

NewScopedAttributeFunction · 0.92
topNIntFunction · 0.85
totalOccurrencesMethod · 0.80
avgSizePerRowGroupMethod · 0.80
topNFunction · 0.70
StringMethod · 0.45

Tested by

no test coverage detected