Store the current request ID in a thread-level variable

pull/15778/head
Rafa de la Torre 4 years ago
parent 027a91deab
commit f2949a35a2

@ -10,6 +10,7 @@ class ApplicationController < ActionController::Base
helper :all
around_filter :set_request_id
around_filter :wrap_in_profiler
before_filter :set_security_headers
@ -141,6 +142,15 @@ class ApplicationController < ActionController::Base
end
end
def set_request_id
Carto::CurrentRequest.request_id = request.uuid
begin
yield
ensure
Carto::CurrentRequest.request_id = nil
end
end
def wrap_in_profiler
if params[:profile_request].present? && current_user.present? && current_user.has_feature_flag?('profiler')
CartoDB::Profiler.new().call(request, response) { yield }

@ -0,0 +1,11 @@
module Carto
module CurrentRequest
def self.request_id
Thread.current[:request_id]
end
def self.request_id=(request_id)
Thread.current[:request_id] = request_id
end
end
end
Loading…
Cancel
Save