class Quilt::Performance::Client
Public Class Methods
new(report)
click to toggle source
# File lib/quilt_rails/performance/client.rb, line 6 def initialize(report) @report = report @base_tags = { browser_connection_type: report.connection.effective_type, }.freeze @distribution_callback = proc { |_name, _value, _tags| nil } @event_callback = proc { |_event, _tags| {} } @navigation_callback = proc { |_navigation, _tags| {} } end
send!(report) { |client| ... }
click to toggle source
# File lib/quilt_rails/performance/client.rb, line 17 def self.send!(report) client = Client.new(report) # Allow the user to customize things if block_given? yield(client) end client.send(:process_report!) end
Public Instance Methods
distribution(metric_name, value, tags = {})
click to toggle source
# File lib/quilt_rails/performance/client.rb, line 28 def distribution(metric_name, value, tags = {}) @distribution_callback.call(metric_name, value, tags) StatsD.distribution(metric_name, value, tags: tags) unless Rails.env.dev? end
on_distribution(&block)
click to toggle source
# File lib/quilt_rails/performance/client.rb, line 41 def on_distribution(&block) @distribution_callback = block end
on_event(&block)
click to toggle source
# File lib/quilt_rails/performance/client.rb, line 37 def on_event(&block) @event_callback = block end
Private Instance Methods
process_report!()
click to toggle source
# File lib/quilt_rails/performance/client.rb, line 47 def process_report! report_events report_navigations end
report_events()
click to toggle source
# File lib/quilt_rails/performance/client.rb, line 52 def report_events @report.events.each do |event| event_tags = @base_tags.dup @event_callback.call(event, event_tags) distribution(event.metric_name, event.value, event_tags) end end