Class: PlainApm::Transport
- Inherits:
-
Object
- Object
- PlainApm::Transport
- Defined in:
- lib/plain_apm/transport.rb
Constant Summary collapse
- HTTP_READ_TIMEOUT_SECONDS =
TODO: tune these.
8
- HTTP_WRITE_TIMEOUT_SECONDS =
default is 60
8
- HTTP_OPEN_TIMEOUT_SECONDS =
default is 60
8
- HTTP_TIMEOUTS =
default is 60
[ Net::OpenTimeout, Net::ReadTimeout, Net::WriteTimeout ].compact.freeze
- ERRNO_ERRORS =
[ Errno::ECONNABORTED, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::EHOSTDOWN, Errno::EHOSTUNREACH, Errno::EINVAL, Errno::ENETUNREACH, Errno::EPIPE ].freeze
Instance Method Summary collapse
-
#deliver(data, meta = {}) ⇒ Array
Performs the actual HTTP request.
-
#initialize(endpoint:, app_key:, http_client: Net::HTTP) ⇒ Transport
constructor
A new instance of Transport.
Constructor Details
#initialize(endpoint:, app_key:, http_client: Net::HTTP) ⇒ Transport
Returns a new instance of Transport.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/plain_apm/transport.rb', line 38 def initialize(endpoint:, app_key:, http_client: Net::HTTP) @uri = URI.parse(endpoint) @app_key = app_key @http = http_client.new(uri.host, uri.port) # Forgotten /, e.g. https://example.com:3000 uri.path = "/" if uri.path.nil? || uri.path.empty? # TODO: our own CA bundle? http.use_ssl = uri.scheme == "https" http.open_timeout = HTTP_OPEN_TIMEOUT_SECONDS http.read_timeout = HTTP_READ_TIMEOUT_SECONDS http.write_timeout = HTTP_WRITE_TIMEOUT_SECONDS at_exit { shutdown } end |
Instance Method Details
#deliver(data, meta = {}) ⇒ Array
Performs the actual HTTP request.
61 62 63 64 65 |
# File 'lib/plain_apm/transport.rb', line 61 def deliver(data, = {}) http_response do http_request(http, uri.path, data, ) end end |