Public: Module that overrides Thread initialization to preserve the request context.
April 11, 2015 ยท View on GitHub
module ThreadWithContext
Public: Returns a new Thread that preserves the context of the current request.
def new(*args) request_id = Thread.current[:request_id] super(*args) { Thread.current[:request_id] = request_id yield *args } end end
Use at your own peril, when you modify stdlib classes many things can go wrong :)
Thread.class_eval do class << self prepend ThreadWithContext end end