Class: Datadog::DI::Transport Private
- Inherits:
-
Object
- Object
- Datadog::DI::Transport
- Defined in:
- lib/datadog/di/transport.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.
Transport for sending probe statuses and snapshots to local agent.
Handles encoding of the payloads into multipart posts if necessary, body formatting/encoding, setting correct headers, etc.
The transport does not handle batching of statuses or snapshots - the batching should be implemented upstream of this class.
Timeout settings are forwarded from agent settings to the Net adapter.
The send_* methods raise Error::AgentCommunicationError on errors (network errors and HTTP protocol errors). It is the responsibility of upstream code to rescue these exceptions appropriately to prevent them from being propagated to the application.
Constant Summary collapse
- DIAGNOSTICS_PATH =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'/debugger/v1/diagnostics'
- INPUT_PATH =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'/debugger/v1/input'
Instance Method Summary collapse
-
#initialize(agent_settings) ⇒ Transport
constructor
private
A new instance of Transport.
- #send_diagnostics(payload) ⇒ Object (also: #send_status) private
- #send_input(payload) ⇒ Object (also: #send_snapshot) private
Constructor Details
#initialize(agent_settings) ⇒ 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.
27 28 29 30 31 |
# File 'lib/datadog/di/transport.rb', line 27 def initialize(agent_settings) # Note that this uses host, port, timeout and TLS flag from # agent settings. @client = Core::Transport::HTTP::Adapters::Net.new(agent_settings) end |
Instance Method Details
#send_diagnostics(payload) ⇒ Object Also known as: send_status
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.
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/datadog/di/transport.rb', line 33 def send_diagnostics(payload) event_payload = Core::Vendor::Multipart::Post::UploadIO.new( StringIO.new(JSON.dump(payload)), 'application/json', 'event.json' ) payload = {'event' => event_payload} # Core transport unconditionally specifies headers to underlying # Net::HTTP client, ends up passing 'nil' as headers if none are # specified by us, which then causes Net::HTTP to die with an exception. send_request('Probe status submission', path: DIAGNOSTICS_PATH, form: payload, headers: {}) end |
#send_input(payload) ⇒ Object Also known as: send_snapshot
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.
45 46 47 48 49 |
# File 'lib/datadog/di/transport.rb', line 45 def send_input(payload) send_request('Probe snapshot submission', path: INPUT_PATH, body: payload.to_s, headers: {'content-type' => 'application/json'},) end |