Class: Aws::Xray::Trace

Inherits:
Object
  • Object
show all
Defined in:
lib/aws/xray/trace.rb

Overview

Imutable

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root:, sampled:, parent: nil, rest: {}) ⇒ Trace

Returns a new instance of Trace.



45
46
47
48
49
50
# File 'lib/aws/xray/trace.rb', line 45

def initialize(root:, sampled:, parent: nil, rest: {})
  @root = root
  @sampled = sampled
  @parent = parent
  @rest = rest
end

Instance Attribute Details

#parentObject (readonly)

Returns the value of attribute parent.



43
44
45
# File 'lib/aws/xray/trace.rb', line 43

def parent
  @parent
end

#rootObject (readonly)

Returns the value of attribute root.



43
44
45
# File 'lib/aws/xray/trace.rb', line 43

def root
  @root
end

Class Method Details

.build_from_header_value(header_value, now = Time.now) ⇒ Object



13
14
15
16
17
18
# File 'lib/aws/xray/trace.rb', line 13

def build_from_header_value(header_value, now = Time.now)
  h = HeaderParser.parse(header_value)
  root = h['Root'] || generate_root(now)
  rest = h.dup.tap {|e| %w[Root Sampled Parent].each {|k| e.delete(k) } }
  new(root: root, sampled: decide_sampling(h['Sampled']), parent: h['Parent'], rest: rest)
end

.generate(now = Time.now) ⇒ Object



9
10
11
# File 'lib/aws/xray/trace.rb', line 9

def generate(now = Time.now)
  new(root: generate_root(now), sampled: decide_sampling(nil))
end

Instance Method Details

#copy(parent: @parent) ⇒ Object



64
65
66
# File 'lib/aws/xray/trace.rb', line 64

def copy(parent: @parent)
  self.class.new(root: @root.dup, sampled: @sampled, parent: parent ? parent.dup : nil)
end

#has_parent?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/aws/xray/trace.rb', line 60

def has_parent?
  !!@parent
end

#sampled?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/aws/xray/trace.rb', line 56

def sampled?
  @sampled
end

#to_header_valueObject



52
53
54
# File 'lib/aws/xray/trace.rb', line 52

def to_header_value
  to_header_hash.map {|k, v| "#{k}=#{v}" }.join(';')
end