Class: ScoutApm::JobRecord
- Inherits:
-
Object
- Object
- ScoutApm::JobRecord
- Defined in:
- lib/scout_apm/job_record.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#exclusive_time ⇒ Object
readonly
Returns the value of attribute exclusive_time.
-
#job_name ⇒ Object
readonly
Returns the value of attribute job_name.
-
#metric_set ⇒ Object
readonly
Returns the value of attribute metric_set.
-
#queue_name ⇒ Object
readonly
Returns the value of attribute queue_name.
-
#total_time ⇒ Object
readonly
Returns the value of attribute total_time.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Hash Key interface.
-
#combine!(other) ⇒ Object
Modifies self and returns self, after merging in ‘other`.
- #eql?(o) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(queue_name, job_name, total_time, exclusive_time, errors, metrics) ⇒ JobRecord
constructor
A new instance of JobRecord.
- #metrics ⇒ Object
- #run_count ⇒ Object
Constructor Details
#initialize(queue_name, job_name, total_time, exclusive_time, errors, metrics) ⇒ JobRecord
Returns a new instance of JobRecord.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/scout_apm/job_record.rb', line 17 def initialize(queue_name, job_name, total_time, exclusive_time, errors, metrics) @queue_name = queue_name @job_name = job_name @total_time = NumericHistogram.new(50) @total_time.add(total_time) @exclusive_time = NumericHistogram.new(50) @exclusive_time.add(exclusive_time) @errors = errors.to_i @metric_set = MetricSet.new @metric_set.absorb_all(metrics) end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
14 15 16 |
# File 'lib/scout_apm/job_record.rb', line 14 def errors @errors end |
#exclusive_time ⇒ Object (readonly)
Returns the value of attribute exclusive_time.
13 14 15 |
# File 'lib/scout_apm/job_record.rb', line 13 def exclusive_time @exclusive_time end |
#job_name ⇒ Object (readonly)
Returns the value of attribute job_name.
11 12 13 |
# File 'lib/scout_apm/job_record.rb', line 11 def job_name @job_name end |
#metric_set ⇒ Object (readonly)
Returns the value of attribute metric_set.
15 16 17 |
# File 'lib/scout_apm/job_record.rb', line 15 def metric_set @metric_set end |
#queue_name ⇒ Object (readonly)
Returns the value of attribute queue_name.
10 11 12 |
# File 'lib/scout_apm/job_record.rb', line 10 def queue_name @queue_name end |
#total_time ⇒ Object (readonly)
Returns the value of attribute total_time.
12 13 14 |
# File 'lib/scout_apm/job_record.rb', line 12 def total_time @total_time end |
Instance Method Details
#==(o) ⇒ Object
Hash Key interface
59 60 61 |
# File 'lib/scout_apm/job_record.rb', line 59 def ==(o) self.eql?(o) end |
#combine!(other) ⇒ Object
Modifies self and returns self, after merging in ‘other`.
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/scout_apm/job_record.rb', line 34 def combine!(other) same_job = queue_name == other.queue_name && job_name == other.job_name raise "Mismatched Merge of Background Job" unless same_job @errors += other.errors @metric_set = metric_set.combine!(other.metric_set) @total_time.combine!(other.total_time) @exclusive_time.combine!(other.exclusive_time) self end |
#eql?(o) ⇒ Boolean
69 70 71 72 73 |
# File 'lib/scout_apm/job_record.rb', line 69 def eql?(o) self.class == o.class && queue_name.downcase == o.queue_name.downcase && job_name.downcase == o.job_name.downcase end |
#hash ⇒ Object
63 64 65 66 67 |
# File 'lib/scout_apm/job_record.rb', line 63 def hash h = queue_name.downcase.hash h ^= job_name.downcase.hash h end |
#metrics ⇒ Object
50 51 52 |
# File 'lib/scout_apm/job_record.rb', line 50 def metrics metric_set.metrics end |
#run_count ⇒ Object
46 47 48 |
# File 'lib/scout_apm/job_record.rb', line 46 def run_count total_time.total end |