Class: CWlogsIO::LogEventHandler
Constant Summary collapse
- EVENTS_PER_CHUNK =
docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutLogEvents.html The maximum batch size is 1,048,576 bytes, and this size is calculated as the sum of all event messages in UTF-8, plus 26 bytes for each log event. 26 bytes is the length of the JSON structure that surrounds the log event information: Each log event can be no larger than 256 KB. The maximum number of log events in a batch is 10,000 When there are 100 events in one chunk, the average size of each event can be up to a maximum of 10kB.
100
Constants inherited from Handler
Handler::DEFAULT_POLLING_PERIOD_IN_SECONDS, Handler::TERMINATION_TIMEOUT_IN_SECONDS
Instance Method Summary collapse
-
#initialize(client, log_group, log_stream, logger, polling_rate = nil) ⇒ LogEventHandler
constructor
A new instance of LogEventHandler.
- #process_events(events) ⇒ Object
Methods inherited from Handler
#<<, #close, #closed?, #enq, #respawn
Constructor Details
#initialize(client, log_group, log_stream, logger, polling_rate = nil) ⇒ LogEventHandler
Returns a new instance of LogEventHandler.
21 22 23 24 25 26 |
# File 'lib/cwlogs_io/io.rb', line 21 def initialize(client, log_group, log_stream, logger, polling_rate = nil) super(logger, polling_rate) @client = client @log_group = log_group @log_stream = log_stream end |
Instance Method Details
#process_events(events) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/cwlogs_io/io.rb', line 28 def process_events(events) events.sort_by!(&:timestamp) Utils.chunks(events, EVENTS_PER_CHUNK).each do |event_chunk| send_events(event_chunk) end end |