Class: Datadog::Core::Remote::Transport::HTTP::Client

Inherits:
Object
  • Object
show all
Includes:
Datadog::Core::Remote::Transport::HTTP::Config::Client, Negotiation::Client
Defined in:
lib/datadog/core/remote/transport/http/client.rb

Overview

Routes, encodes, and sends tracer data to the trace agent via HTTP.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Negotiation::Client

#send_info_payload

Methods included from Datadog::Core::Remote::Transport::HTTP::Config::Client

#send_config_payload

Constructor Details

#initialize(api) ⇒ Client

Returns a new instance of Client.



20
21
22
# File 'lib/datadog/core/remote/transport/http/client.rb', line 20

def initialize(api)
  @api = api
end

Instance Attribute Details

#apiObject (readonly)

Returns the value of attribute api.



18
19
20
# File 'lib/datadog/core/remote/transport/http/client.rb', line 18

def api
  @api
end

Instance Method Details

#build_env(request) ⇒ Object



40
41
42
# File 'lib/datadog/core/remote/transport/http/client.rb', line 40

def build_env(request)
  Datadog::Core::Transport::HTTP::Env.new(request)
end

#send_request(request, &block) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/datadog/core/remote/transport/http/client.rb', line 24

def send_request(request, &block)
  # Build request into env
  env = build_env(request)

  # Get responses from API
  yield(api, env)
rescue StandardError => e
  message =
    "Internal error during #{self.class.name} request. Cause: #{e.class.name} #{e.message} " \
      "Location: #{Array(e.backtrace).first}"

  Datadog.logger.debug(message)

  Datadog::Core::Transport::InternalErrorResponse.new(e)
end