Skip to content

Commit

Permalink
fix: Capture all params even if more than one have same types
Browse files Browse the repository at this point in the history
  • Loading branch information
jhutar committed Jun 2, 2024
1 parent 4af1f97 commit 676fddb
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/load-tests/pkg/logging/time_and_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,23 @@ func Measure(fn interface{}, params ...interface{}) (interface{}, error) {
args[i] = reflect.ValueOf(params[i])
}

// Create map of parameters with key being parameter type (I do not
// know how to access parameter name) and value parameter value
// Because of that we are adding index to key to ensure we capture
// all params even when multiple of params have same type.
paramsStorable := make(map[string]string)
for i := 0; i < numParams; i++ {
x := 1
key := fmt.Sprintf("%v", reflect.TypeOf(params[i]))
value := fmt.Sprintf("%+v", reflect.ValueOf(params[i]))
paramsStorable[key] = value
for {
keyFull := key + string(x)
if _, ok := paramsStorable[keyFull]; !ok {
paramsStorable[keyFull] = value
break
}
x++
}
}

var errInterValue error
Expand Down

0 comments on commit 676fddb

Please sign in to comment.