Skip to content

Commit

Permalink
pkg/trace/testutil: improve the randomization in test spans generator (
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmed-mez authored Jan 18, 2023
1 parent 6576cba commit 9837685
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/trace/testutil/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,13 @@ func int32RandomChoice(s []int32) int32 {
}

func stringRandomChoice(s []string) string {
return randomChoice(stringSlice(s)).(string)
got := randomChoice(stringSlice(s)).(string)
runes := []rune(got)
rand.Shuffle(len(runes), func(x, y int) {
// Add more randomization by shuffling the characters
runes[x], runes[y] = runes[y], runes[x]
})
return string(runes)
}

// RandomSpanDuration generates a random span duration
Expand Down

0 comments on commit 9837685

Please sign in to comment.