@@ -101,18 +101,24 @@ defmodule OtelMetricExporter.LogAccumulator do
101101 { :noreply , Map . merge ( state , Map . merge ( rest , % { api: api } ) ) }
102102 end
103103
104- # Do nothing on an empty queue
105- def handle_info ( :send_log_batch , % { event_queue: [ ] } = state ) , do: { :noreply , state }
106-
107- def handle_info ( :send_log_batch , state )
108- when map_size ( state . pending_tasks ) < state . api . otlp_concurrent_requests do
109- # We can spin up a new task to send the logs
110- { :noreply , send_events_via_task ( state ) }
111- end
112-
113- # No task budget, so we're blocking on this message
114104 def handle_info ( :send_log_batch , state ) do
115- { :noreply , state |> block_until_any_task_ready ( ) |> send_events_via_task ( ) }
105+ # Reset the timer
106+ state = Map . put ( state , :timer_ref , nil )
107+
108+ case state do
109+ % { event_queue: [ ] } ->
110+ # Do nothing on an empty queue
111+ { :noreply , state }
112+
113+ % { pending_tasks: pending_tasks , api: api }
114+ when map_size ( pending_tasks ) < api . otlp_concurrent_requests ->
115+ # We have some task budget, let's put in a task
116+ { :noreply , send_events_via_task ( state ) }
117+
118+ _ ->
119+ # No task budget, so we're blocking on this message
120+ { :noreply , state |> block_until_any_task_ready ( ) |> send_events_via_task ( ) }
121+ end
116122 end
117123
118124 def handle_info ( { ref , result } , state )
0 commit comments