Class: Appdash::Span::ID

Inherits:
Object
  • Object
show all
Defined in:
lib/appdash/span/id.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent = nil) ⇒ ID

Creates a new root span

Parameters:

  • parent, (Appdash::SpanID)

    optional parent



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

#parentObject (readonly)



14
15
16
# File 'lib/appdash/span/id.rb', line 14

def parent
  @parent
end

#spanObject (readonly)



11
12
13
# File 'lib/appdash/span/id.rb', line 11

def span
  @span
end

#traceObject (readonly)



8
9
10
# File 'lib/appdash/span/id.rb', line 8

def trace
  @trace
end

Instance Method Details

#childAppdash::SpanID

Returns creates a child span.

Returns:

  • (Appdash::SpanID)

    creates a child span



25
26
27
# File 'lib/appdash/span/id.rb', line 25

def child
  self.class.new(self)
end

#to_sString

Returns string ID.

Returns:

  • (String)

    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