Class: Sqreen::PerformanceNotifications::Metrics
- Defined in:
- lib/sqreen/performance_notifications/metrics.rb
Overview
Log performances in sqreen metrics_store
Constant Summary collapse
- EVENT_CAT =
'sqreen_time'.freeze
Class Method Summary collapse
- .disable ⇒ Object
- .enable(metrics_engine, period = 60) ⇒ Object
- .log(rule, cb, start, finish, _meta) ⇒ Object
Methods inherited from Log
Class Method Details
.disable ⇒ Object
32 33 34 35 36 |
# 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) ⇒ Object
24 25 26 27 28 29 30 |
# 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) ⇒ Object
18 19 20 21 22 |
# File 'lib/sqreen/performance_notifications/metrics.rb', line 18 def log(rule, cb, start, finish, ) event = event_name(rule, cb) evt = [EVENT_CAT, event, (finish - start) * 1000, Time.now.utc] Sqreen.observations_queue.push(evt) end |