Sha256: 7b416d9bb42f9ca0514af0258e700c009a94d7426f80ba1f51a608c79826d3c7
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 KB
Contents
module SystemMetrics class Engine < ::Rails::Engine attr_accessor :collector, :smc config.system_metrics = SystemMetrics::Config.new initializer "system_metrics.initialize" do |app| self.smc = app.config.system_metrics raise ArgumentError.new(smc.errors) if smc.invalid? self.collector = SystemMetrics::Collector.new(smc.store) end initializer "system_metrics.start_subscriber" do |app| ActiveSupport::Notifications.subscribe /^[^!]/ do |*args| unless smc.notification_exclude_patterns.any? { |pattern| pattern =~ name } process_event SystemMetrics::NestedEvent.new(*args) end end end initializer "system_metrics.add_middleware" do |app| app.config.middleware.use SystemMetrics::Middleware, collector, smc.path_exclude_patterns end private def process_event(event) instrument = smc.instruments.find { |instrument| instrument.handles?(event) } if instrument.present? unless instrument.ignore?(event) instrument.prepare(event) collector.collect_event(event) end else collector.collect_event(event) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
system-metrics-0.1.0 | lib/system_metrics/engine.rb |