Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

Allow open_timeout and read_timeout to be set from ENV vars #153

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/librato/metrics/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def transport
raise(NoClientProvided, "No client provided.") unless @client
@transport ||= Faraday::Connection.new(
url: api_endpoint + "/v1/",
request: {open_timeout: 20, timeout: 30}) do |f|
request: { open_timeout: open_timeout, timeout: read_timeout }) do |f|

f.use Librato::Metrics::Middleware::RequestBody
f.use Librato::Metrics::Middleware::Retry
Expand Down Expand Up @@ -81,6 +81,14 @@ def adapter_version
end
end

def open_timeout
ENV.fetch("LIBRATO_OPEN_TIMEOUT", 20)
end

def read_timeout
ENV.fetch("LIBRATO_READ_TIMEOUT", 30)
end

def ruby_engine
return RUBY_ENGINE if Object.constants.include?(:RUBY_ENGINE)
RUBY_DESCRIPTION.split[0]
Expand Down