You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
587 B

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. # frozen_string_literal: true
  2. # Base Application
  3. class ApplicationController < ActionController::Base
  4. MAX_DURATION_TO_COMPLETE_IN_SECONDS = 3
  5. around_action do |_, action|
  6. start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  7. begin
  8. action.call
  9. ensure
  10. duration = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
  11. if duration > MAX_DURATION_TO_COMPLETE_IN_SECONDS
  12. logger.warn('processing took too long to complete, please review your code as asynchronous job!',
  13. duration: duration * 1_000)
  14. end
  15. end
  16. end
  17. end