class Sqreen::PerformanceNotifications::Metrics

Log performances in sqreen metrics_store

Constants

EVENT_CAT

Public Class Methods

disable() click to toggle source
# File lib/sqreen/performance_notifications/metrics.rb, line 32
def disable
  return if @subid.nil?
  Sqreen::PerformanceNotifications.unsubscribe(@subid)
  @subid = nil
end
enable(metrics_engine, period = 60) click to toggle source
# File lib/sqreen/performance_notifications/metrics.rb, line 24
def enable(metrics_engine, period = 60)
  return unless @subid.nil?
  metrics_engine.create_metric('name' => EVENT_CAT,
                               'period' => period,
                               'kind' => 'Average')
  @subid = Sqreen::PerformanceNotifications.subscribe(&method(:log))
end
log(rule, cb, start, finish, _meta) click to toggle source
# File lib/sqreen/performance_notifications/metrics.rb, line 18
def log(rule, cb, start, finish, _meta)
  event = event_name(rule, cb)
  evt = [EVENT_CAT, event, (finish - start) * 1000, Time.now.utc]
  Sqreen.observations_queue.push(evt)
end