class ElasticAPM::Transport::Connection

def perform_request_in_thread

rubocop:disable Metrics/MethodLength
def perform_request_in_thread
  @conn_thread = Thread.new do
    begin
      @connected = true
      resp = @client.post(@url, body: @rd).flush
    rescue Exception => e
      @connection_error = e
    ensure
      @connected = false
    end
    if resp&.status == 202
      debug 'APM Server responded with status 202'
    elsif resp
      error "APM Server reponded with an error:\n%p", resp.body.to_s
    end
    resp
  end
end