class Sqreen::Legacy::OldEventSubmissionStrategy
see also Sqreen::Signals::SignalsSubmissionStrategy
usage in Sqreen:Session
Constants
- RETRY_MANY
Public Class Methods
new(post_proc)
click to toggle source
# File lib/sqreen/legacy/old_event_submission_strategy.rb, line 20 def initialize(post_proc) @post_proc = post_proc end
Public Instance Methods
post_attack(attack)
click to toggle source
@param attack [Sqreen::Attack]
# File lib/sqreen/legacy/old_event_submission_strategy.rb, line 31 def post_attack(attack) post('attack', EventToHash.convert_attack(attack), {}, RETRY_MANY) end
post_batch(events)
click to toggle source
# File lib/sqreen/legacy/old_event_submission_strategy.rb, line 53 def post_batch(events) batch = events.map do |event| h = case event when AggregatedMetric logger.warn "Aggregated metric event in non-signal mode. Signals disabled at runtime?" next when Sqreen::Kit::Signals::Signal logger.warn "Signal event in non-signal mode" next when Sqreen::Kit::Signals::Trace logger.warn "Trace event in non-signal mode" next when Attack # in practice only found inside req rec EventToHash.convert_attack event when RemoteException EventToHash.convert_exception event when RequestRecord EventToHash.convert_request_record event else logger.warn "Unexpected event type: #{event}" next end h['event_type'] = event_kind(event) h end Sqreen.log.debug do tally = Hash[events.group_by(&:class).map { |k, v| [k, v.count] }] "Doing batch with the following tally of event types: #{tally}" end post('batch', { batch: batch.compact }, {}, RETRY_MANY) end
post_metrics(metrics)
click to toggle source
# File lib/sqreen/legacy/old_event_submission_strategy.rb, line 24 def post_metrics(metrics) return if metrics.nil? || metrics.empty? payload = { metrics: metrics.map { |m| EventToHash.convert_agg_metric(m) } } post('metrics', payload, {}, RETRY_MANY) end
post_request_record(request_record)
click to toggle source
@param [Sqreen::RequestRecord] request_record
# File lib/sqreen/legacy/old_event_submission_strategy.rb, line 36 def post_request_record(request_record) rr_hash = EventToHash.convert_request_record(request_record) post('request_record', rr_hash, {}, RETRY_MANY) end
post_sqreen_exception(exception)
click to toggle source
Post an exception to Sqreen
for analysis @param exception [RemoteException] Exception
and context to be sent over
# File lib/sqreen/legacy/old_event_submission_strategy.rb, line 43 def post_sqreen_exception(exception) data = EventToHash.convert_exception(exception) post('sqreen_exception', data, {}, 5) rescue StandardError => e logger.warn(format('Could not post exception (network down? %s) %s', e.inspect, exception.inspect)) nil end
Private Instance Methods
event_kind(event)
click to toggle source
# File lib/sqreen/legacy/old_event_submission_strategy.rb, line 92 def event_kind(event) case event when Sqreen::RemoteException then 'sqreen_exception' when Sqreen::Attack then 'attack' when Sqreen::RequestRecord then 'request_record' end end
post(*args)
click to toggle source
see Sqreen::Session.post
# File lib/sqreen/legacy/old_event_submission_strategy.rb, line 88 def post(*args) @post_proc[*args] end