Class: Datadog::DI::Transport::Diagnostics::Transport Private
- Inherits:
-
Object
- Object
- Datadog::DI::Transport::Diagnostics::Transport
- Defined in:
- lib/datadog/di/transport/diagnostics.rb
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.
Instance Attribute Summary collapse
- #apis ⇒ Object readonly private
- #client ⇒ Object readonly private
- #current_api_id ⇒ Object readonly private
- #default_api ⇒ Object readonly private
- #logger ⇒ Object readonly private
Instance Method Summary collapse
- #current_api ⇒ Object private
-
#initialize(apis, default_api, logger:) ⇒ Transport
constructor
private
A new instance of Transport.
- #send_diagnostics(payload) ⇒ Object private
Constructor Details
#initialize(apis, default_api, logger:) ⇒ Transport
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 Transport.
20 21 22 23 24 25 |
# File 'lib/datadog/di/transport/diagnostics.rb', line 20 def initialize(apis, default_api, logger:) @apis = apis @logger = logger @client = HTTP::Client.new(current_api, logger: logger) end |
Instance Attribute Details
#apis ⇒ Object (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.
18 19 20 |
# File 'lib/datadog/di/transport/diagnostics.rb', line 18 def apis @apis end |
#client ⇒ Object (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.
18 19 20 |
# File 'lib/datadog/di/transport/diagnostics.rb', line 18 def client @client end |
#current_api_id ⇒ Object (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.
18 19 20 |
# File 'lib/datadog/di/transport/diagnostics.rb', line 18 def current_api_id @current_api_id end |
#default_api ⇒ Object (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.
18 19 20 |
# File 'lib/datadog/di/transport/diagnostics.rb', line 18 def default_api @default_api end |
#logger ⇒ Object (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.
18 19 20 |
# File 'lib/datadog/di/transport/diagnostics.rb', line 18 def logger @logger end |
Instance Method Details
#current_api ⇒ 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.
27 28 29 |
# File 'lib/datadog/di/transport/diagnostics.rb', line 27 def current_api @apis[HTTP::API::DIAGNOSTICS] end |
#send_diagnostics(payload) ⇒ 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.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/datadog/di/transport/diagnostics.rb', line 31 def send_diagnostics(payload) json = JSON.dump(payload) parcel = EncodedParcel.new(json) request = Request.new(parcel) response = @client.send_diagnostics_payload(request) unless response.ok? # TODO Datadog::Core::Transport::InternalErrorResponse # does not have +code+ method, what is the actual API of # these response objects? raise Error::AgentCommunicationError, "send_diagnostics failed: #{begin response.code rescue "???" end}: #{response.payload}" end rescue Error::AgentCommunicationError raise # Datadog::Core::Transport does not perform any exception mapping, # therefore we could have any exception here from failure to parse # agent URI for example. # If we ever implement retries for network errors, we should distinguish # actual network errors from non-network errors that are raised by # transport code. rescue => exc raise Error::AgentCommunicationError, "send_diagnostics failed: #{exc.class}: #{exc}" end |