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

Function generateFeature

pkg/drain/testdata/generate-random-span-names/main.go:50–79  ·  view source on GitHub ↗
(feature string, r *rand.Rand)

Source from the content-addressed store, hash-verified

48}
49
50func generateFeature(feature string, r *rand.Rand) string {
51 switch feature {
52 case "<ip>":
53 return fmt.Sprintf("%d.%d.%d.%d", r.Intn(256), r.Intn(256), r.Intn(256), r.Intn(256))
54 case "<base64>":
55 return base64.StdEncoding.EncodeToString(randomBytes(r, 10))
56 case "<uuid>":
57 return uuid.New().String()
58 case "<word>":
59 return randomWord(r)
60 case "<word-list>":
61 return randomWordList(r)
62 case "<method>":
63 return randomMethod(r)
64 case "<protocol>":
65 return randomProtocol(r)
66 case "<md5>":
67 return hex.EncodeToString(md5.New().Sum(randomBytes(r, 10))) //nolint:gosec // this is a test tool
68 case "<alphanumeric>":
69 return randomAlphanumeric(r)
70 case "<number>":
71 return strconv.Itoa(r.Intn(1000))
72 case "<sqlkeyword>":
73 return randomSQLKeyword(r)
74 case "<sql>":
75 return randomSQL(r)
76 default:
77 return feature
78 }
79}
80
81func randomSQLKeyword(r *rand.Rand) string {
82 statements := []string{

Callers 1

generateSpanNameFunction · 0.85

Calls 10

randomBytesFunction · 0.85
randomWordFunction · 0.85
randomWordListFunction · 0.85
randomMethodFunction · 0.85
randomProtocolFunction · 0.85
randomAlphanumericFunction · 0.85
randomSQLKeywordFunction · 0.85
randomSQLFunction · 0.85
EncodeToStringMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected