class Datadog::Core::Telemetry::Http::Adapters::Net
Class defining methods to make http requests via NET
def initialize(hostname:, port: nil, timeout: DEFAULT_TIMEOUT, ssl: true)
def initialize(hostname:, port: nil, timeout: DEFAULT_TIMEOUT, ssl: true) @hostname = hostname @port = port @timeout = timeout @ssl = ssl.nil? ? true : ssl end
def open(&block)
def open(&block) req = ::Net::HTTP.new(@hostname, @port) req.use_ssl = @ssl req.open_timeout = req.read_timeout = @timeout req.start(&block) end
def post(env)
def post(env) begin post = ::Net::HTTP::Post.new(env.path, env.headers) post.body = env.body http_response = open do |http| http.request(post) end Response.new(http_response) rescue StandardError => e Datadog.logger.debug("Unable to send telemetry event to agent: #{e}") Telemetry::Http::InternalErrorResponse.new(e) end end