Module: ILove::Tracing::RequestId

Defined in:
lib/ilove/tracing/request_id.rb

Defined Under Namespace

Classes: RequestIdFaradayMiddleware, RequestIdRackMiddleware

Class Method Summary collapse

Class Method Details

.cfgObject



6
7
8
# File 'lib/ilove/tracing/request_id.rb', line 6

def self.cfg
  @@cfg
end

.request_idObject



10
11
12
# File 'lib/ilove/tracing/request_id.rb', line 10

def self.request_id
  Thread.current[:request_id]
end

.request_id=(val) ⇒ Object



14
15
16
# File 'lib/ilove/tracing/request_id.rb', line 14

def self.request_id=(val)
  Thread.current[:request_id] = val
end

.setup(cfg) ⇒ Object



44
45
46
47
48
49
50
51
# File 'lib/ilove/tracing/request_id.rb', line 44

def self.setup(cfg)
  raise 'pass request id requires rails' unless defined?(::Rails)
  raise 'pass request id requires faraday' unless defined?(::Faraday)

  @@cfg = cfg
  Rails.application.middleware.unshift RequestIdRackMiddleware
  ILove::Tracing::FaradayMiddleware.add_active_middleware RequestIdFaradayMiddleware
end