module Oboe::Inst::EventMachine::HttpClient

Public Instance Methods

parse_response_header_with_oboe(*args, &block) click to toggle source
# File lib/oboe/inst/em-http-request.rb, line 31
def parse_response_header_with_oboe(*args, &block)
  report_kvs = {}
  xtrace = nil
  blacklisted = Oboe::API.blacklisted?(@uri)

  begin
    report_kvs[:HTTPStatus] = args[2]
    report_kvs[:Async] = 1
  rescue => e
    Oboe.logger.debug "[oboe/debug] em-http-request KV error: #{e.inspect}"
  end

  parse_response_header_without_oboe(*args, &block)

  unless blacklisted
    headers = args[0]
    context = Oboe::Context.toString
    task_id = Oboe::XTrace.task_id(context)

    if headers.is_a?(Hash) && headers.key?('X-Trace')
      xtrace = headers['X-Trace']
    end

    if Oboe::XTrace.valid?(xtrace) && Oboe.tracing?

      # Assure that we received back a valid X-Trace with the same task_id
      if task_id == Oboe::XTrace.task_id(xtrace)
        Oboe::Context.fromString(xtrace)
      else
        Oboe.logger.debug "Mismatched returned X-Trace ID : #{xtrace}"
      end
    end

  end

  ::Oboe::API.log_exit('em-http-request', report_kvs)
end