Class: Shoryuken::Middleware::Server::Timing

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/shoryuken/middleware/server/timing.rb

Instance Method Summary collapse

Methods included from Util

#elapsed, #fire_event, #logger, #unparse_queues, #worker_name

Instance Method Details

#call(_worker, queue, _sqs_msg, _body) ⇒ Object


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/shoryuken/middleware/server/timing.rb', line 7

def call(_worker, queue, _sqs_msg, _body)
  started_at = Time.now

  logger.info { "started at #{started_at}" }

  yield

  total_time = elapsed(started_at)

  if (total_time / 1000.0) > (timeout = Shoryuken::Client.queues(queue).visibility_timeout)
    logger.warn { "exceeded the queue visibility timeout by #{total_time - (timeout * 1000)} ms" }
  end

  logger.info { "completed in: #{total_time} ms" }
rescue
  logger.info { "failed in: #{elapsed(started_at)} ms" }
  raise
end