class TCellAgent::Instrumentation::Rails::Middleware::ContextMiddleware
Constants
- THREADS
Public Class Methods
new(app)
click to toggle source
# File lib/tcell_agent/rails/middleware/context_middleware.rb, line 14 def initialize(app) @app = app end
Public Instance Methods
call(env)
click to toggle source
# File lib/tcell_agent/rails/middleware/context_middleware.rb, line 18 def call(env) if TCellAgent.configuration.should_intercept_requests? env[TCellAgent::Instrumentation::TCELL_ID] = TCellAgent::Instrumentation::TCellData.new TCellAgent::Instrumentation.safe_block('Setting transaction_id') do env[TCellAgent::Instrumentation::TCELL_ID].transaction_id = SecureRandom.uuid request = Rack::Request.new(env) env[TCellAgent::Instrumentation::TCELL_ID].uri = request.url env[TCellAgent::Instrumentation::TCELL_ID].fullpath = request.fullpath env[TCellAgent::Instrumentation::TCELL_ID].path = request.path env[TCellAgent::Instrumentation::TCELL_ID].user_agent = request.user_agent env[TCellAgent::Instrumentation::TCELL_ID].referrer = request.referrer env[TCellAgent::Instrumentation::TCELL_ID].remote_address = request.ip env[TCellAgent::Instrumentation::TCELL_ID].reverse_proxy_header_value = TCellAgent::Utils::Rails.reverse_proxy_header(request) if request.request_method env[TCellAgent::Instrumentation::TCELL_ID].request_method = request.request_method end end env['filter_body_set'] = Set.new ContextMiddleware::THREADS[Thread.current.object_id] = env end response = @app.call(env) if TCellAgent.configuration.should_intercept_requests? ContextMiddleware::THREADS.delete(Thread.current.object_id) end response end