Module: Resque::Plugins::Analytics
- Defined in:
- lib/resque-analytics/server.rb,
lib/resque/plugins/analytics.rb
Defined Under Namespace
Modules: Server
Constant Summary collapse
- FAILED =
"failed"- PERFORMED =
"performed"- TOTAL_TIME =
"total_time"- WAIT_TIME =
"wait_time"- EXPIRE =
90.days.to_i
Class Method Summary collapse
Instance Method Summary collapse
- #after_perform_analytics(*args) ⇒ Object
- #analytics_timestamp(timestamp) ⇒ Object
- #around_perform_analytics(*args) ⇒ Object
- #field(kpi) ⇒ Object
- #key ⇒ Object
- #on_failure_analytics(error, *args) ⇒ Object
Class Method Details
.ignore_classes ⇒ Object
38 39 40 |
# File 'lib/resque/plugins/analytics.rb', line 38 def self.ignore_classes @ignore_classes || [] end |
.ignore_classes=(class_array) ⇒ Object
34 35 36 |
# File 'lib/resque/plugins/analytics.rb', line 34 def self.ignore_classes=(class_array) @ignore_classes = class_array end |
Instance Method Details
#after_perform_analytics(*args) ⇒ Object
60 61 62 63 |
# File 'lib/resque/plugins/analytics.rb', line 60 def after_perform_analytics(*args) Resque.redis.hincrby(key, field(PERFORMED), 1) Resque.redis.expire(key, EXPIRE) end |
#analytics_timestamp(timestamp) ⇒ Object
70 71 72 73 |
# File 'lib/resque/plugins/analytics.rb', line 70 def () Resque.redis.hincrbyfloat(key, field(WAIT_TIME), Time.now - Time.parse()) Resque.redis.expire(key, EXPIRE) end |
#around_perform_analytics(*args) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/resque/plugins/analytics.rb', line 51 def around_perform_analytics(*args) start = Time.now yield total_time = Time.now - start Resque.redis.hincrbyfloat(key, field(TOTAL_TIME), total_time) Resque.redis.expire(key, EXPIRE) end |
#field(kpi) ⇒ Object
47 48 49 |
# File 'lib/resque/plugins/analytics.rb', line 47 def field(kpi) "#{self.name}:#{kpi}" end |
#key ⇒ Object
42 43 44 45 |
# File 'lib/resque/plugins/analytics.rb', line 42 def key date = Time.now.strftime("%y_%m_%d") "resque-analytics:#{date}" end |