Class: Datadog::Transport::HTTP::Adapters::UnixSocket

Inherits:
Net
  • Object
show all
Defined in:
lib/ddtrace/transport/http/adapters/unix_socket.rb

Overview

Adapter for Unix sockets

Defined Under Namespace

Classes: HTTP

Constant Summary

Constants inherited from Net

Net::DEFAULT_TIMEOUT

Instance Attribute Summary collapse

Attributes inherited from Net

#hostname, #port, #ssl

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Net

#call, #post

Constructor Details

#initialize(uds_path = nil, **options) ⇒ UnixSocket

Deprecated.

Positional parameters are deprecated. Use named parameters instead.

Returns a new instance of UnixSocket.



19
20
21
22
# File 'lib/ddtrace/transport/http/adapters/unix_socket.rb', line 19

def initialize(uds_path = nil, **options)
  @filepath = uds_path || options.fetch(:uds_path)
  @timeout = options[:timeout] || Ext::Transport::UnixSocket::DEFAULT_TIMEOUT_SECONDS
end

Instance Attribute Details

#filepathObject (readonly) Also known as: uds_path

Returns the value of attribute filepath.



12
13
14
# File 'lib/ddtrace/transport/http/adapters/unix_socket.rb', line 12

def filepath
  @filepath
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



12
13
14
# File 'lib/ddtrace/transport/http/adapters/unix_socket.rb', line 12

def timeout
  @timeout
end

Class Method Details

.build(agent_settings) ⇒ Object



24
25
26
27
28
29
# File 'lib/ddtrace/transport/http/adapters/unix_socket.rb', line 24

def self.build(agent_settings)
  new(
    uds_path: agent_settings.uds_path,
    timeout: agent_settings.timeout_seconds,
  )
end

Instance Method Details

#open(&block) ⇒ Object



31
32
33
34
35
36
37
38
39
40
# File 'lib/ddtrace/transport/http/adapters/unix_socket.rb', line 31

def open(&block)
  # Open connection
  connection = HTTP.new(
    uds_path,
    read_timeout: timeout,
    continue_timeout: timeout
  )

  connection.start(&block)
end

#urlObject



42
43
44
# File 'lib/ddtrace/transport/http/adapters/unix_socket.rb', line 42

def url
  "http+unix://#{uds_path}?timeout=#{timeout}"
end