Class: Datadog::DI::Transport::HTTP::Client Private

Inherits:
Object
  • Object
show all
Includes:
Diagnostics::Client, Input::Client
Defined in:
lib/datadog/di/transport/http/client.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Input::Client

#send_input_payload

Methods included from Diagnostics::Client

#send_diagnostics_payload

Constructor Details

#initialize(api, logger:) ⇒ Client

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Client.



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

def initialize(api, logger:)
  @api = api
  @logger = logger
end

Instance Attribute Details

#apiObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



17
18
19
# File 'lib/datadog/di/transport/http/client.rb', line 17

def api
  @api
end

#loggerObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



17
18
19
# File 'lib/datadog/di/transport/http/client.rb', line 17

def logger
  @logger
end

Instance Method Details

#build_env(request) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

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

#send_request(request, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/datadog/di/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 => e
  message =
    "Internal error during #{self.class.name} request. Cause: #{e.class.name} #{e.message} " \
      "Location: #{Array(e.backtrace).first}"

  logger.debug(message)

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