Method: Libhoney::ExperimentalTransmissionClient#add

Defined in:
lib/libhoney/experimental_transmission.rb

#add(event) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/libhoney/experimental_transmission.rb', line 25

def add(event)
  return unless event_valid(event)

  begin
    # if block_on_send is true, never timeout the wait to enqueue an event
    # otherwise, timeout the wait immediately and if the queue is full, we'll
    # have a ThreadError raised because we could not add to the queue.
    timeout = @block_on_send ? :never : 0
    @batch_queue.enq(event, timeout)
  rescue Libhoney::Queueing::SizedQueueWithTimeout::PushTimedOut
    # happens if the queue was full and block_on_send = false.
    warn "#{self.class.name}: batch queue full, dropping event." if %w[debug trace].include?(ENV['LOG_LEVEL'])
  end

  ensure_threads_running
end