Class: Appdash::Span

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

Defined Under Namespace

Classes: ID

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Span

Returns a new instance of Span.



12
13
14
15
16
17
# File 'lib/appdash/span.rb', line 12

def initialize(client)
  @client  = client
  @packets = []
  @root_id = Appdash::Span::ID.new
  @id      = root_id
end

Instance Attribute Details

#idObject (readonly)



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

def id
  @id
end

#root_idObject (readonly)



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

def root_id
  @root_id
end

Instance Method Details

#event(evt) ⇒ Object

Appends a generic Appdash::Event event



35
36
37
38
# File 'lib/appdash/span.rb', line 35

def event(evt)
  @packets.push Appdash::CollectPacket.build(evt, @id)
  @id = @id.child
end

#flushObject



40
41
42
43
44
45
# File 'lib/appdash/span.rb', line 40

def flush
  count = @packets.size
  @client.send :write, @packets
  @packets.clear
  count
end

#log(msg) ⇒ Object

Appends a new Appdash::Event::Log event



30
31
32
# File 'lib/appdash/span.rb', line 30

def log(msg)
  event Appdash::Event::Log.new(msg)
end

#message(msg) ⇒ Object

Appends a new Appdash::Event::Message event



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

def message(msg)
  event Appdash::Event::Message.new(msg)
end

#name(val) ⇒ Object

Appends a new Appdash::Event::SpanName event



20
21
22
# File 'lib/appdash/span.rb', line 20

def name(val)
  event Appdash::Event::SpanName.new(val)
end