-
Notifications
You must be signed in to change notification settings - Fork 11
Refactor NewValue, add tests #16
Refactor NewValue, add tests #16
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, a couple of minor comments. I am curious about the impact of the use of reflection here since it is generally known to be expensive, and I think we could probably avoid it for common cases for primitive types.
We are going to execute this for every event processed by the shipper so the cost of this conversion will definitely show up in our performance tests.
Alright, made a few performance changes, which seems to have helped:
|
} | ||
} | ||
|
||
func TestStructValue(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We aren't hitting a few cases in this test or the benchmarks looking at the code coverage with:
go test ./pkg/helpers/... -coverprofile=cover.tmp
go tool cover -html cover.tmp
We are missing the map[string]interface{}
and reflect.Slice
cases which both seem important enough to test. Hitting all the primitive number cases is probably easy to do but also unlikely to matter that much.
I am giving this PR extra scrutiny because any problems here mean the shipper just doesn't work at all, or works unnecessarily slowly :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh man, I completely forgot about the -coverprofile
feature, haven't used that in years.
Alright, going over the coverage profile made me realize that the
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all the iterations!
I suspect we may eventually want a way to know we are falling back on reflection, but in theory it will show up in the profiles in our performance tests.
I would tag a release for this fix before updating Beats + the shipper. |
Closes elastic/beats#34319
There's a few things going on here:
NewValue
to make it a little more hardy, and to better handle the[]string
values that were causing the failures seen in the above issue.go-version
manually, since it was a tad out of date