feat(event): Add MultiValueEvent interface and MultiObserverEvent implementation #602
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces the first step in refactoring the event handling system to better support multiple values in a single event, which will help reduce allocations when processing events. This is part of a larger effort to improve performance and reduce memory allocations in the statsd_exporter.
Changes:
MultiValueEvent
interface that supports multiple values per eventMultiObserverEvent
implementation for handling multiple observationsExplodableEvent
interface for backward compatibilityValues()
method to existing event typesThis is the first PR of a two-part series of changes I plan on doing.
Here is the overall plan I have in my head:
Part 1
Introduce the
MultiValueEvent
interface and theMultiObserverEvent
implementation.With support for "exploding" the event into an slice of events, this will help users that use the project as a library to migrate the code when we break interface.
Part 2 (⚠️ BREAKING)
Introduce some kind of EventExploder and create a new EventQueue to accept a channel of
event.MultiValueEvent
instead of receiving a channel ofevent.Events
(i.e. slice of Events).Also rename the current EventQueue to LegacyEventQueue which allows users to use the old behavior, annotate this as deprecated.
Relates to #577