class Kiev::ContextReader

Abstracts common details about reading tracing context into Kiev's request store. Subclass and override [] to change field lookup.

Constants

REQUEST_DEPTH
REQUEST_ID
TRACKING_ID
TREE_PATH

Attributes

subject[R]

Public Class Methods

new(subject) click to toggle source
# File lib/kiev/context_reader.rb, line 13
def initialize(subject)
  @subject = subject
end

Public Instance Methods

[](key) click to toggle source
# File lib/kiev/context_reader.rb, line 17
def [](key)
  subject[key]
end
request_depth() click to toggle source
# File lib/kiev/context_reader.rb, line 31
def request_depth
  tree_root? ? 0 : (self[REQUEST_DEPTH].to_i + 1)
end
request_id()
Alias for: tracking_id
tracking_id() click to toggle source
# File lib/kiev/context_reader.rb, line 21
def tracking_id
  self[TRACKING_ID] || self[REQUEST_ID] || SecureRandom.uuid
end
Also aliased as: request_id
tree_path() click to toggle source
# File lib/kiev/context_reader.rb, line 35
def tree_path
  if tree_root?
    SubrequestHelper.root_path(synchronous: false)
  else
    self[TREE_PATH]
  end
end
tree_root?() click to toggle source
# File lib/kiev/context_reader.rb, line 27
def tree_root?
  !self[TRACKING_ID] && !self[REQUEST_ID]
end