-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Closed
Labels
Milestone
Description
Search before asking
- I had searched in the issues and found no similar issues.
Apache SkyWalking Component
OAP server (apache/skywalking)
What happened
When using go agent to enhance a function with multiple parameters of the same type, If the function is in the following format: func myFunc(x, y, z string) {}, it can only be obtained in invocation.Args() of Interceptor.BeforeInvoke a parameter x
What you expected to happen
I think we should be able to get the three parameters x, y and z
How to reproduce
Enhance a function like the following
func myFunc(x, y, z string) {}
Anything else
I checked the source code and found that when traversing dst.Field.Names, break was used. Should it be continue?
func EnhanceParameterNames(fields *dst.FieldList, fieldType FieldListType) []*ParameterInfo {
if fields == nil {
return nil
}
result := make([]*ParameterInfo, 0)
for i, f := range fields.List {
var defineName string
switch fieldType {
case FieldListTypeParam:
defineName = fmt.Sprintf("skywalking_param_%d", i)
case FieldListTypeResult:
defineName = fmt.Sprintf("skywalking_result_%d", i)
case FieldListTypeRecv:
defineName = fmt.Sprintf("skywalking_recv_%d", i)
}
if len(f.Names) == 0 {
f.Names = []*dst.Ident{{Name: defineName}}
result = append(result, newParameterInfo(defineName, f.Type))
} else {
for _, n := range f.Names {
if n.Name == "_" {
*n = *dst.NewIdent(defineName)
break
}
}
for _, n := range f.Names {
result = append(result, newParameterInfo(n.Name, f.Type))
break
}
}
}
return result
}
Are you willing to submit a pull request to fix on your own?
- Yes I am willing to submit a pull request on my own!
Code of Conduct
- I agree to follow this project's Code of Conduct