Class: Chillout::Middleware::SidekiqJobMeasurement
- Inherits:
-
Object
- Object
- Chillout::Middleware::SidekiqJobMeasurement
- Defined in:
- lib/chillout/middleware/sidekiq.rb
Instance Attribute Summary collapse
-
#delay ⇒ Object
readonly
Returns the value of attribute delay.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#finished ⇒ Object
readonly
Returns the value of attribute finished.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#retriable ⇒ Object
readonly
Returns the value of attribute retriable.
-
#started ⇒ Object
readonly
Returns the value of attribute started.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
Instance Method Summary collapse
- #as_measurements ⇒ Object
-
#initialize(job, queue, started, finished, success) ⇒ SidekiqJobMeasurement
constructor
A new instance of SidekiqJobMeasurement.
- #job_class ⇒ Object
Constructor Details
#initialize(job, queue, started, finished, success) ⇒ SidekiqJobMeasurement
Returns a new instance of SidekiqJobMeasurement.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/chillout/middleware/sidekiq.rb', line 8 def initialize(job, queue, started, finished, success) @class = job["class"].to_s @retriable = job["retry"].to_s @queue = queue @started = started.utc @finished = finished.utc enqueued_at = job["enqueued_at"] || @finished.to_f @delay = 1000.0 * (@finished.to_f - enqueued_at) @duration = 1000.0 * (@finished.to_f - @started.to_f) @success = success.to_s end |
Instance Attribute Details
#delay ⇒ Object (readonly)
Returns the value of attribute delay.
5 6 7 |
# File 'lib/chillout/middleware/sidekiq.rb', line 5 def delay @delay end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
5 6 7 |
# File 'lib/chillout/middleware/sidekiq.rb', line 5 def duration @duration end |
#finished ⇒ Object (readonly)
Returns the value of attribute finished.
5 6 7 |
# File 'lib/chillout/middleware/sidekiq.rb', line 5 def finished @finished end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
5 6 7 |
# File 'lib/chillout/middleware/sidekiq.rb', line 5 def queue @queue end |
#retriable ⇒ Object (readonly)
Returns the value of attribute retriable.
5 6 7 |
# File 'lib/chillout/middleware/sidekiq.rb', line 5 def retriable @retriable end |
#started ⇒ Object (readonly)
Returns the value of attribute started.
5 6 7 |
# File 'lib/chillout/middleware/sidekiq.rb', line 5 def started @started end |
#success ⇒ Object (readonly)
Returns the value of attribute success.
5 6 7 |
# File 'lib/chillout/middleware/sidekiq.rb', line 5 def success @success end |
Instance Method Details
#as_measurements ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/chillout/middleware/sidekiq.rb', line 24 def as_measurements() [{ series: "sidekiq_jobs", tags: { class: @class, retriable: @retriable, queue: @queue, success: @success.to_s, }, timestamp: @finished.iso8601, values: { finished: 1, duration: @duration.to_f, delay: @delay.to_f }, }] end |
#job_class ⇒ Object
20 21 22 |
# File 'lib/chillout/middleware/sidekiq.rb', line 20 def job_class @class end |