Class: Appdash::Span::ID
- Inherits:
-
Object
- Object
- Appdash::Span::ID
- Defined in:
- lib/appdash/span/id.rb
Instance Attribute Summary collapse
- #parent ⇒ Object readonly
- #span ⇒ Object readonly
- #trace ⇒ Object readonly
Instance Method Summary collapse
-
#child ⇒ Appdash::SpanID
Creates a child span.
-
#initialize(parent = nil) ⇒ ID
constructor
Creates a new root span.
-
#to_s ⇒ String
String ID.
Constructor Details
#initialize(parent = nil) ⇒ ID
Creates a new root span
18 19 20 21 22 |
# File 'lib/appdash/span/id.rb', line 18 def initialize(parent = nil) @trace = parent ? parent.trace : random_uint64 @span = random_uint64 @parent = parent.span if parent end |
Instance Attribute Details
#parent ⇒ Object (readonly)
14 15 16 |
# File 'lib/appdash/span/id.rb', line 14 def parent @parent end |
#span ⇒ Object (readonly)
11 12 13 |
# File 'lib/appdash/span/id.rb', line 11 def span @span end |
#trace ⇒ Object (readonly)
8 9 10 |
# File 'lib/appdash/span/id.rb', line 8 def trace @trace end |
Instance Method Details
#child ⇒ Appdash::SpanID
Returns creates a child span.
25 26 27 |
# File 'lib/appdash/span/id.rb', line 25 def child self.class.new(self) end |
#to_s ⇒ String
Returns string ID.
30 31 32 33 34 |
# File 'lib/appdash/span/id.rb', line 30 def to_s [trace, span, parent].compact.map do |num| num.to_s(16).rjust(16, '0') end.join("/") end |