Class: Datadog::Core::Telemetry::Http::Transport
- Inherits:
-
Object
- Object
- Datadog::Core::Telemetry::Http::Transport
- Defined in:
- lib/datadog/core/telemetry/http/transport.rb
Overview
Class to send telemetry data to Telemetry API Currently only supports the HTTP protocol.
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#ssl ⇒ Object
readonly
Returns the value of attribute ssl.
Class Method Summary collapse
- .build_agent_transport(agent_settings) ⇒ Object
- .build_agentless_transport(api_key:, dd_site:, url_override: nil) ⇒ Object
Instance Method Summary collapse
-
#initialize(host:, port:, path:, ssl: false, api_key: nil) ⇒ Transport
constructor
A new instance of Transport.
- #request(request_type:, payload:) ⇒ Object
Constructor Details
#initialize(host:, port:, path:, ssl: false, api_key: nil) ⇒ Transport
Returns a new instance of Transport.
47 48 49 50 51 52 53 |
# File 'lib/datadog/core/telemetry/http/transport.rb', line 47 def initialize(host:, port:, path:, ssl: false, api_key: nil) @host = host @port = port @ssl = ssl @path = path @api_key = api_key end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
40 41 42 |
# File 'lib/datadog/core/telemetry/http/transport.rb', line 40 def api_key @api_key end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
40 41 42 |
# File 'lib/datadog/core/telemetry/http/transport.rb', line 40 def host @host end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
40 41 42 |
# File 'lib/datadog/core/telemetry/http/transport.rb', line 40 def path @path end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
40 41 42 |
# File 'lib/datadog/core/telemetry/http/transport.rb', line 40 def port @port end |
#ssl ⇒ Object (readonly)
Returns the value of attribute ssl.
40 41 42 |
# File 'lib/datadog/core/telemetry/http/transport.rb', line 40 def ssl @ssl end |
Class Method Details
.build_agent_transport(agent_settings) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/datadog/core/telemetry/http/transport.rb', line 17 def self.build_agent_transport(agent_settings) Transport.new( host: agent_settings.hostname, port: agent_settings.port, path: Http::Ext::AGENT_ENDPOINT ) end |
.build_agentless_transport(api_key:, dd_site:, url_override: nil) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/datadog/core/telemetry/http/transport.rb', line 25 def self.build_agentless_transport(api_key:, dd_site:, url_override: nil) url = url_override || "https://#{Http::Ext::AGENTLESS_HOST_PREFIX}.#{dd_site}:443" uri = URI.parse(url) raise "Invalid agentless mode URL: #{url}" if uri.host.nil? Transport.new( host: uri.host, port: uri.port || 80, path: Http::Ext::AGENTLESS_ENDPOINT, ssl: uri.scheme == 'https' || uri.port == 443, api_key: api_key ) end |