Class: Airbrake::Backlog Private
- Inherits:
-
Object
- Object
- Airbrake::Backlog
- Includes:
- Loggable
- Defined in:
- lib/airbrake-ruby/backlog.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Backlog accepts notices and APM events and synchronously sends them in the background at regular intervals. The backlog is a queue of data that failed to be sent due to some error. In a nutshell, it’s a retry mechanism.
Constant Summary collapse
- BACKLOG_SIZE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Returns how many records to keep in the backlog.
100
- TWO_MINUTES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Returns flush period in seconds.
60 * 2
Instance Method Summary collapse
-
#<<(data) ⇒ self
private
Appends data to the backlog.
-
#close ⇒ void
private
Closes all the resources that this sender has allocated.
-
#initialize(sync_sender, flush_period = TWO_MINUTES) ⇒ Backlog
constructor
private
A new instance of Backlog.
Methods included from Loggable
Constructor Details
#initialize(sync_sender, flush_period = TWO_MINUTES) ⇒ Backlog
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Backlog.
17 18 19 20 21 22 23 24 25 |
# File 'lib/airbrake-ruby/backlog.rb', line 17 def initialize(sync_sender, flush_period = TWO_MINUTES) @sync_sender = sync_sender @flush_period = flush_period @queue = SizedQueue.new(BACKLOG_SIZE).extend(MonitorMixin) @has_backlog_data = @queue.new_cond @schedule_flush = nil @seen = Set.new end |
Instance Method Details
#<<(data) ⇒ self
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Appends data to the backlog. Once appended, the flush schedule will start. Chainable.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/airbrake-ruby/backlog.rb', line 37 def <<(data) @queue.synchronize do return self if @seen.include?(data) @seen << data begin @queue.push(data, true) rescue ThreadError logger.error("#{LOG_LABEL} Airbrake::Backlog full") return self end @has_backlog_data.signal schedule_flush self end end |
#close ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Closes all the resources that this sender has allocated.
61 62 63 64 65 66 67 68 |
# File 'lib/airbrake-ruby/backlog.rb', line 61 def close @queue.synchronize do if @schedule_flush @schedule_flush.kill logger.debug("#{LOG_LABEL} Airbrake::Backlog closed") end end end |