[breaking] Reduce allocations in LineToEvents
by returning a single event instead of an slice
#577
Labels
enhancement
library
Issues pertaining to the use of the packages as a library more than the exporter itself
Description
The current implementation of the
LineToEvents
method inpkg/line/line.go
returns multiple events, which results in a lot of allocations in the statsd-exporter. We propose changing this method to return a single event instead.On the same refactoring step, we should introduce a "exploder" or "sampling" layer (or helper method on the event) which will keep the same behavior as we have now.
This is a breaking change on purpose which will force client projects using this repository as a library, to adapt to the new method signature.
Here is an example profile with samples using sampling rate, where you can see it takes more than 21% of total memory used:
Goals
Count
orSamplingRate
to another layer of the exporter.Proposed Solution
LineToEvents
method to return a single event.Count
orSamplingRate
in the event structure.Count
orSamplingRate
.Repro script
The text was updated successfully, but these errors were encountered: