Sha256: a21c421dac982e60e5e8f602f000ee983846b86f70bc0d707f3516fd10c45a21
Contents?: true
Size: 1.19 KB
Versions: 12
Compression:
Stored size: 1.19 KB
Contents
# Copyright (c) 2015 Sqreen. All Rights Reserved. # Please refer to our terms for more information: https://www.sqreen.com/terms.html require 'sqreen/performance_notifications' require 'sqreen/performance_notifications/log' require 'sqreen/runner' module Sqreen module PerformanceNotifications # Log performances in sqreen metrics_store class Metrics < Log @subid = nil @facility = nil class << self EVENT_CAT = 'sqreen_time'.freeze 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 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 def disable return if @subid.nil? Sqreen::PerformanceNotifications.unsubscribe(@subid) @subid = nil end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems