Sha256: ace5cdc6941aba4d954161ce2c4c141e6a196d4d082254caa95be3eee7dfd79b
Contents?: true
Size: 1.02 KB
Versions: 3
Compression:
Stored size: 1.02 KB
Contents
module Pallets module Middleware class JobLogger def self.call(worker, job, context) start_time = current_time Pallets.logger.with_metadata(extract_metadata(worker.id, job)) do begin Pallets.logger.info 'Started' result = yield Pallets.logger.info "Done in #{(current_time - start_time).round(3)}s" result rescue => ex Pallets.logger.warn "Failed after #{(current_time - start_time).round(3)}s" Pallets.logger.warn "#{ex.class.name}: #{ex.message}" Pallets.logger.warn ex.backtrace.join("\n") unless ex.backtrace.nil? raise end end end def self.extract_metadata(wid, job) { wid: wid, wfid: job['wfid'], jid: job['jid'], wf: job['workflow_class'], tsk: job['task_class'], } end def self.current_time Process.clock_gettime(Process::CLOCK_MONOTONIC) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pallets-0.11.0 | lib/pallets/middleware/job_logger.rb |
pallets-0.10.0 | lib/pallets/middleware/job_logger.rb |
pallets-0.9.0 | lib/pallets/middleware/job_logger.rb |