Class: DTrace::Data

Inherits:
Object
  • Object
show all
Defined in:
lib/dtrace/data.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(types) ⇒ Data

Returns a new instance of Data.



13
14
15
16
17
18
# File 'lib/dtrace/data.rb', line 13

def initialize(types)
  @types = types
  @data = []
  @curraggset = nil
  @curragg    = nil
end

Instance Attribute Details

#cpuObject (readonly)

Returns the value of attribute cpu.



11
12
13
# File 'lib/dtrace/data.rb', line 11

def cpu
  @cpu
end

#dataObject (readonly)

Returns the value of attribute data.



9
10
11
# File 'lib/dtrace/data.rb', line 9

def data
  @data
end

#flowObject (readonly)

Returns the value of attribute flow.



11
12
13
# File 'lib/dtrace/data.rb', line 11

def flow
  @flow
end

#indentObject (readonly)

Returns the value of attribute indent.



11
12
13
# File 'lib/dtrace/data.rb', line 11

def indent
  @indent
end

#prefixObject (readonly)

Returns the value of attribute prefix.



11
12
13
# File 'lib/dtrace/data.rb', line 11

def prefix
  @prefix
end

#probeObject (readonly)

Returns the value of attribute probe.



10
11
12
# File 'lib/dtrace/data.rb', line 10

def probe
  @probe
end

Instance Method Details

#add_bufdata(buf) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/dtrace/data.rb', line 56

def add_bufdata(buf)
  r = buf.record

  p r

  # buf records can be empty (trace();)
  if r
    case r.class.to_s
    when DTrace::StackRecord.to_s
      add_data(r)
    when DTrace::Record.to_s
      add_data(r)
    when DTrace::PrintfRecord.to_s
      add_data(r)
    when DTrace::AggData.to_s
      if @curragg == nil
        @curragg = DTrace::Aggregate.new
      end
      if agg = @curragg.add_record(r)
        if @curraggset
          @curraggset.add_aggregate(@curragg)
        end
        @curragg = nil
      end
    end
  end
end

#add_data(d) ⇒ Object



20
21
22
23
24
# File 'lib/dtrace/data.rb', line 20

def add_data(d)
  if @types.length == 0 || @types.include?(d.class)
    @data << d
  end
end

#add_probedata(probedata) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/dtrace/data.rb', line 43

def add_probedata(probedata)
  probedata.each_record do |p|
    add_data(p)
  end

  # Record the probe that fired, and CPU/indent/prefix/flow
  @probe  = probedata.probe
  @cpu    = probedata.cpu
  @indent = probedata.indent
  @prefix = probedata.prefix
  @flow   = probedata.flow
end

#add_recdata(rec) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/dtrace/data.rb', line 33

def add_recdata(rec)
  if @curraggset
    add_data(@curraggset)
    @curraggset = nil
  end
  if rec.action == "printa"
    @curraggset = DTrace::AggregateSet.new
  end
end

#finishObject



26
27
28
29
30
31
# File 'lib/dtrace/data.rb', line 26

def finish
  if @curraggset
    add_data(@curraggset)
    @curraggset = nil
  end
end