Method: Logtail::LogDevices::HTTP#initialize
- Defined in:
- lib/logtail/log_devices/http.rb
#initialize(source_token, options = {}) ⇒ HTTP
Instantiates a new HTTP log device that can be passed to Logtail::Logger#initialize.
The class maintains a buffer which is flushed in batches to the Logtail API. 2 options control when the flush happens, ‘:batch_byte_size` and `:flush_interval`. If either of these are surpassed, the buffer will be flushed.
By default, the buffer will apply back pressure when the rate of log messages exceeds the maximum delivery rate. If you don’t want to sacrifice app performance in this case you can drop the log messages instead by passing a DroppingSizedQueue via the ‘:request_queue` option.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/logtail/log_devices/http.rb', line 71 def initialize(source_token, = {}) # Handle backward-compatibility of argument names [:ingesting_host] ||= [:logtail_host] [:ingesting_port] ||= [:logtail_port] [:ingesting_scheme] ||= [:logtail_scheme] @source_token = source_token || raise(ArgumentError.new("The source_token parameter cannot be blank")) @ingesting_host = [:ingesting_host] || ENV['INGESTING_HOST'] || ENV['LOGTAIL_HOST'] || DEFAULT_INGESTING_HOST @ingesting_port = [:ingesting_port] || ENV['INGESTING_PORT'] || ENV['LOGTAIL_PORT'] || DEFAULT_INGESTING_PORT @ingesting_scheme = [:ingesting_scheme] || ENV['INGESTING_SCHEME'] || ENV['LOGTAIL_SCHEME'] || DEFAULT_INGESTING_SCHEME @batch_size = [:batch_size] || 1_000 @flush_continuously = [:flush_continuously] != false @flush_interval = [:flush_interval] || 2 # 2 seconds @requests_per_conn = [:requests_per_conn] || 2_500 @msg_queue = FlushableDroppingSizedQueue.new(@batch_size) @request_queue = [:request_queue] || FlushableDroppingSizedQueue.new(25) @successive_error_count = 0 @requests_in_flight = 0 end |