Class: Aws::Xray::Trace
- Inherits:
-
Object
- Object
- Aws::Xray::Trace
- Defined in:
- lib/aws/xray/trace.rb
Overview
Imutable
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Class Method Summary collapse
Instance Method Summary collapse
- #copy(parent: @parent) ⇒ Object
- #has_parent? ⇒ Boolean
-
#initialize(root:, sampled:, parent: nil, rest: {}) ⇒ Trace
constructor
A new instance of Trace.
- #sampled? ⇒ Boolean
- #to_header_value ⇒ Object
Constructor Details
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
43 44 45 |
# File 'lib/aws/xray/trace.rb', line 43 def parent @parent end |
#root ⇒ Object (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
60 61 62 |
# File 'lib/aws/xray/trace.rb', line 60 def has_parent? !!@parent end |
#sampled? ⇒ Boolean
56 57 58 |
# File 'lib/aws/xray/trace.rb', line 56 def sampled? @sampled end |
#to_header_value ⇒ Object
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 |