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: true, parent: nil) ⇒ 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.
26 27 28 |
# File 'lib/aws/xray/trace.rb', line 26 def parent @parent end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
26 27 28 |
# File 'lib/aws/xray/trace.rb', line 26 def root @root end |
Class Method Details
.build_from_header_value(header_value, now = Time.now) ⇒ Object
13 14 15 16 17 |
# 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) new(root: root, sampled: h['Sampled'] != '0', parent: h['Parent']) 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)) end |
Instance Method Details
#copy(parent: @parent) ⇒ Object
49 50 51 |
# File 'lib/aws/xray/trace.rb', line 49 def copy(parent: @parent) self.class.new(root: @root.dup, sampled: @sampled, parent: parent ? parent.dup : nil) end |
#has_parent? ⇒ Boolean
45 46 47 |
# File 'lib/aws/xray/trace.rb', line 45 def has_parent? !!@parent end |
#sampled? ⇒ Boolean
41 42 43 |
# File 'lib/aws/xray/trace.rb', line 41 def sampled? @sampled end |
#to_header_value ⇒ Object
34 35 36 37 38 39 |
# File 'lib/aws/xray/trace.rb', line 34 def to_header_value v = "Root=#{@root};" sampled? ? v << 'Sampled=1' : v << 'Sampled=0' v << ";Parent=#{@parent}" if has_parent? v end |