Skip to content

Commit

Permalink
finishOngoing() when min send duration expires
Browse files Browse the repository at this point in the history
Otherwise we won't actually send the events 🤦
  • Loading branch information
sharnoff committed Jan 29, 2025
1 parent 4b90b35 commit 95a12a0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/reporting/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ func (s eventSender[E]) senderLoop(ctx context.Context, logger *zap.Logger) {
case <-s.batchComplete.Wait():
s.batchComplete.Awake() // consume this notification
case <-timer.C:
// Timer has expired without any notification of a completed batch. Let's explicitly ask
// for in-progress events to be wrapped up into a batch so we ship them fast enough and
// reset the timer.
//
// consume s.batchComplete on repeat if there were events; otherwise wait until the
// timer expires again.
s.queue.finishOngoing()
timer.Reset(heartbeat)
continue
}

// Make sure that if there are no more events within the next heartbeat duration, that we'll
Expand Down

0 comments on commit 95a12a0

Please sign in to comment.