Class: Airbrake::PerformanceNotifier

Inherits:
Object
  • Object
show all
Includes:
Inspectable, Loggable
Defined in:
lib/airbrake-ruby/performance_notifier.rb

Overview

PerformanceNotifier aggregates performance data and periodically sends it to Airbrake.

rubocop:disable Metrics/ClassLength

Since:

  • v3.2.0

Constant Summary

Constants included from Inspectable

Inspectable::INSPECT_TEMPLATE

Instance Method Summary collapse

Methods included from Loggable

#logger

Methods included from Inspectable

#inspect, #pretty_print

Constructor Details

#initializePerformanceNotifier

Returns a new instance of PerformanceNotifier.

Since:

  • v3.2.0



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/airbrake-ruby/performance_notifier.rb', line 12

def initialize
  @config = Airbrake::Config.instance
  @flush_period = Airbrake::Config.instance.performance_stats_flush_period
  @async_sender = AsyncSender.new(:put, self.class.name)
  @sync_sender = SyncSender.new(:put)
  @schedule_flush = nil
  @filter_chain = FilterChain.new

  @payload = {}.extend(MonitorMixin)
  @has_payload = @payload.new_cond
end

Instance Method Details

#add_filter(filter = nil, &block) ⇒ Object

See Also:

Since:

  • v3.2.0



41
42
43
# File 'lib/airbrake-ruby/performance_notifier.rb', line 41

def add_filter(filter = nil, &block)
  @filter_chain.add_filter(block_given? ? block : filter)
end

#closeObject

Since:

  • v3.2.0



50
51
52
53
54
55
56
# File 'lib/airbrake-ruby/performance_notifier.rb', line 50

def close
  @payload.synchronize do
    @schedule_flush.kill if @schedule_flush
    @sync_sender.close
    @async_sender.close
  end
end

#delete_filter(filter_class) ⇒ Object

See Also:

Since:

  • v3.2.0



46
47
48
# File 'lib/airbrake-ruby/performance_notifier.rb', line 46

def delete_filter(filter_class)
  @filter_chain.delete_filter(filter_class)
end

#notify(metric) ⇒ Object

Parameters:

  • metric (Hash)

See Also:

Since:

  • v3.2.0



27
28
29
30
31
# File 'lib/airbrake-ruby/performance_notifier.rb', line 27

def notify(metric)
  @payload.synchronize do
    send_metric(metric, sync: false)
  end
end

#notify_sync(metric) ⇒ Object

Parameters:

  • metric (Hash)

See Also:

Since:

  • v4.10.0



36
37
38
# File 'lib/airbrake-ruby/performance_notifier.rb', line 36

def notify_sync(metric)
  send_metric(metric, sync: true).value
end