Skip to content

Commit

Permalink
add unit (s) to duration attribute on log entries
Browse files Browse the repository at this point in the history
  • Loading branch information
alachaum committed Apr 5, 2024
1 parent bf7d8b0 commit 2c1a884
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/cloudtasker/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,16 @@ def execute
resp = execute_middleware_chain

# Log job completion and return result
logger.info("Job done after #{job_duration}s") { { duration: job_duration } }
logger.info("Job done after #{job_duration}s") { { duration: "#{job_duration}s" } }
resp
rescue DeadWorkerError => e
logger.info("Job dead after #{job_duration}s and #{job_retries} retries") { { duration: job_duration } }
logger.info("Job dead after #{job_duration}s and #{job_retries} retries") { { duration: "#{job_duration}s" } }
raise(e)
rescue RetryWorkerError => e
logger.info("Job done after #{job_duration}s (retry requested)") { { duration: job_duration } }
logger.info("Job done after #{job_duration}s (retry requested)") { { duration: "#{job_duration}s" } }
raise(e)
rescue StandardError => e
logger.info("Job failed after #{job_duration}s") { { duration: job_duration } }
logger.info("Job failed after #{job_duration}s") { { duration: "#{job_duration}s" } }
raise(e)
end

Expand Down Expand Up @@ -396,7 +396,7 @@ def arguments_missing?
def job_duration
return 0.0 unless perform_ended_at && perform_started_at

(perform_ended_at - perform_started_at).ceil(3)
@job_duration ||= (perform_ended_at - perform_started_at).ceil(3)
end

#
Expand Down

0 comments on commit 2c1a884

Please sign in to comment.