Class: Nightwing::Sidekiq::Profiler
- Defined in:
- lib/nightwing/sidekiq/profiler.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #call(worker, _msg, queue) ⇒ Object
-
#memory_snapshot ⇒ Object
returns number of bytes used by current process.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Nightwing::Sidekiq::Base
Instance Method Details
#call(worker, _msg, queue) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/nightwing/sidekiq/profiler.rb', line 6 def call(worker, _msg, queue) queue_namespace = metrics.for(queue: queue) worker_namespace = metrics.for(queue: queue, worker: worker.class) begin started_at = Time.now initial_gc_count = ::GC.count initial_snapshot = memory_snapshot yield ensure finish_snapshot = memory_snapshot memory_delta_in_bytes = finish_snapshot - initial_snapshot total_time = ((Time.now - started_at) * 1_000).round total_gc_count = ::GC.count - initial_gc_count client.timing "#{worker_namespace}.time", total_time client.measure "#{worker_namespace}.memory.delta", memory_delta_in_bytes client.measure "#{worker_namespace}.gc.count", total_gc_count client.timing "#{queue_namespace}.time", total_time client.measure "#{queue_namespace}.memory.delta", memory_delta_in_bytes client.measure "#{queue_namespace}.gc.count", total_gc_count end end |
#memory_snapshot ⇒ Object
returns number of bytes used by current process
33 34 35 |
# File 'lib/nightwing/sidekiq/profiler.rb', line 33 def memory_snapshot Oink::Instrumentation::MemorySnapshot.memory end |