class ElasticAPM::Transport::Connection

def write(str)

def write(str)
  return false if @config.disable_send
  begin
    bytes_written = 0
    # The request might get closed from timertask so let's make sure we
    # hold it open until we've written.
    @mutex.synchronize do
      connect if http.nil? || http.closed?
      bytes_written = http.write(str)
    end
    flush(:api_request_size) if bytes_written >= @config.api_request_size
  rescue IOError => e
    error('Connection error: %s', e.inspect)
    flush(:ioerror)
  rescue Errno::EPIPE => e
    error('Connection error: %s', e.inspect)
    flush(:broken_pipe)
  rescue Exception => e
    error('Connection error: %s', e.inspect)
    flush(:connection_error)
  end
end