Class: Sentry::SessionFlusher
- Inherits:
-
ThreadedPeriodicWorker
- Object
- ThreadedPeriodicWorker
- Sentry::SessionFlusher
- Defined in:
- lib/sentry/session_flusher.rb
Constant Summary collapse
- FLUSH_INTERVAL =
60
Instance Method Summary collapse
- #add_session(session) ⇒ Object
- #flush ⇒ Object (also: #run)
-
#initialize(configuration, client) ⇒ SessionFlusher
constructor
A new instance of SessionFlusher.
Methods inherited from ThreadedPeriodicWorker
Constructor Details
#initialize(configuration, client) ⇒ SessionFlusher
Returns a new instance of SessionFlusher.
7 8 9 10 11 12 13 14 15 |
# File 'lib/sentry/session_flusher.rb', line 7 def initialize(configuration, client) super(configuration.logger, FLUSH_INTERVAL) @client = client @pending_aggregates = {} @release = configuration.release @environment = configuration.environment log_debug("[Sessions] Sessions won't be captured without a valid release") unless @release end |
Instance Method Details
#add_session(session) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/sentry/session_flusher.rb', line 26 def add_session(session) return unless @release return unless ensure_thread return unless Session::AGGREGATE_STATUSES.include?(session.status) @pending_aggregates[session.aggregation_key] ||= init_aggregates(session.aggregation_key) @pending_aggregates[session.aggregation_key][session.status] += 1 end |
#flush ⇒ Object Also known as: run
17 18 19 20 21 22 |
# File 'lib/sentry/session_flusher.rb', line 17 def flush return if @pending_aggregates.empty? @client.capture_envelope(pending_envelope) @pending_aggregates = {} end |