Add eventsCounter to keep track of accumulating events
Add eventsCounter
to keep track of a number of accumulating events.
This counter will be used for checking the number of accumulating events, and flush the events if it reaches the limit. I will create another MR to flush the events.
Part of #514 (closed) and #516 (closed).