X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/060d38d627bd1e51dd2b3c6e7de9af6aa7d7b6f3..1471ad4b235e168ccee4fa351b0025b2b380d7ac:/apps/workbench/app/controllers/application_controller.rb diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb index 5acf9a7351..8d9e8578c5 100644 --- a/apps/workbench/app/controllers/application_controller.rb +++ b/apps/workbench/app/controllers/application_controller.rb @@ -11,8 +11,8 @@ class ApplicationController < ActionController::Base ERROR_ACTIONS = [:render_error, :render_not_found] - prepend_before_filter :set_current_request_id, except: ERROR_ACTIONS around_filter :thread_clear + around_filter :set_current_request_id around_filter :set_thread_api_token # Methods that don't require login should # skip_around_filter :require_thread_api_token @@ -573,6 +573,19 @@ class ApplicationController < ActionController::Base Rails.cache.delete_matched(/^request_#{Thread.current.object_id}_/) end + def set_current_request_id + response.headers['X-Request-Id'] = + Thread.current[:request_id] = + "req-" + Random::DEFAULT.rand(2**128).to_s(36)[0..19] + yield + Thread.current[:request_id] = nil + end + + def append_info_to_payload(payload) + super + payload[:request_id] = response.headers['X-Request-Id'] + end + # Set up the thread with the given API token and associated user object. def load_api_token(new_token) Thread.current[:arvados_api_token] = new_token @@ -1307,10 +1320,4 @@ class ApplicationController < ActionController::Base def wiselinks_layout 'body' end - - def set_current_request_id - # Request ID format: '-<9_digits_random_number>' - current_request_id = "#{Time.new.to_i}-#{sprintf('%09d', rand(0..10**9-1))}" - Thread.current[:current_request_id] = current_request_id - end end