Class: Aws::Xray::Trace
- Inherits:
-
Object
- Object
- Aws::Xray::Trace
- Defined in:
- lib/aws/xray/trace.rb
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:) ⇒ 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.
25 26 27 |
# File 'lib/aws/xray/trace.rb', line 25 def parent @parent end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
25 26 27 |
# File 'lib/aws/xray/trace.rb', line 25 def root @root end |
Class Method Details
.build_from_header_value(header_value) ⇒ Object
12 13 14 15 |
# File 'lib/aws/xray/trace.rb', line 12 def build_from_header_value(header_value) h = HeaderParser.parse(header_value) new(root: h.fetch('Root'), sampled: h['Sampled'] != '0', parent: h['Parent']) end |
.generate(now = Time.now) ⇒ Object
8 9 10 |
# File 'lib/aws/xray/trace.rb', line 8 def generate(now = Time.now) new(root: generate_root(now)) end |
Instance Method Details
#copy(parent:) ⇒ Object
48 49 50 |
# File 'lib/aws/xray/trace.rb', line 48 def copy(parent:) self.class.new(root: @root, sampled: @sampled, parent: parent) end |
#has_parent? ⇒ Boolean
44 45 46 |
# File 'lib/aws/xray/trace.rb', line 44 def has_parent? !!@parent end |
#sampled? ⇒ Boolean
40 41 42 |
# File 'lib/aws/xray/trace.rb', line 40 def sampled? @sampled end |
#to_header_value ⇒ Object
33 34 35 36 37 38 |
# File 'lib/aws/xray/trace.rb', line 33 def to_header_value v = "Root=#{@root};" sampled? ? v << 'Sampled=1' : v << 'Sampled=0' v << ";Parent=#{@parent}" if has_parent? v end |