Module: RailsPulse::HasPerformanceStatus

Extended by:
ActiveSupport::Concern
Included in:
Job, JobRun
Defined in:
app/models/concerns/rails_pulse/has_performance_status.rb

Instance Method Summary collapse

Instance Method Details

#performance_statusSymbol

Returns performance status based on configured thresholds

Returns:

  • (Symbol)

    One of :fast, :slow, :very_slow, :critical



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/models/concerns/rails_pulse/has_performance_status.rb', line 19

def performance_status
  thresholds = RailsPulse.configuration.job_thresholds
  attr_name = self.class.get_performance_status_attribute
  duration_value = public_send(attr_name).to_f

  if duration_value < thresholds[:slow]
    :fast
  elsif duration_value < thresholds[:very_slow]
    :slow
  elsif duration_value < thresholds[:critical]
    :very_slow
  else
    :critical
  end
end