class ElasticAPM::Transport::Worker

def work_forever

rubocop:disable Metrics/MethodLength
def work_forever
  while (msg = queue.pop)
    case msg
    when StopMessage
      stop
    else
      process msg
    end
    next unless stopping?
    debug 'Stopping worker -- %s', self
    @connection.flush
    break
  end
rescue Exception => e
  warn 'Worker died with exception: %s', e.inspect
  debug e.backtrace.join("\n")
end