diff --git a/lib/sidetiq/middleware/history.rb b/lib/sidetiq/middleware/history.rb index 0119a09..6752096 100644 --- a/lib/sidetiq/middleware/history.rb +++ b/lib/sidetiq/middleware/history.rb @@ -13,6 +13,7 @@ module Sidetiq def call_with_sidetiq_history(worker, msg, queue) entry = new_history_entry + start_time = Time.now yield rescue StandardError => e @@ -23,6 +24,7 @@ module Sidetiq raise e ensure + entry[:runtime] = (Time.now - start_time) save_entry_for_worker(entry, worker) end @@ -33,7 +35,8 @@ module Sidetiq exception: "", backtrace: "", node: "#{Socket.gethostname}:#{Process.pid}-#{Thread.current.object_id}", - timestamp: Time.now.iso8601 + timestamp: Time.now.iso8601, + runtime: "" } end diff --git a/lib/sidetiq/views/history.erb b/lib/sidetiq/views/history.erb index 7531fa8..4e660c1 100644 --- a/lib/sidetiq/views/history.erb +++ b/lib/sidetiq/views/history.erb @@ -17,6 +17,7 @@ Status Timestamp + Runtime Details @@ -25,6 +26,7 @@ <%= entry[:status].capitalize %> <%= Time.parse(entry[:timestamp]).strftime("%m/%d/%Y %I:%M:%S%p") %> + <%= entry[:runtime].round(3) %> s <% if entry[:status] == 'failure' %>