Class: DtraceData
- Inherits:
-
Object
- Object
- DtraceData
- Defined in:
- lib/dtracedata.rb
Overview
Ruby-Dtrace © 2007 Chris Andrews <[email protected]>
The object returned from a consumer when a probe fires. Accumulates records from the callbacks, and is yielded when the data is complete.
Instance Attribute Summary collapse
-
#cpu ⇒ Object
readonly
Returns the value of attribute cpu.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#flow ⇒ Object
readonly
Returns the value of attribute flow.
-
#indent ⇒ Object
readonly
Returns the value of attribute indent.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#probe ⇒ Object
readonly
Returns the value of attribute probe.
Instance Method Summary collapse
- #add_bufdata(buf) ⇒ Object
- #add_data(d) ⇒ Object
- #add_probedata(probedata) ⇒ Object
- #add_recdata(rec) ⇒ Object
- #finish ⇒ Object
-
#initialize(types) ⇒ DtraceData
constructor
A new instance of DtraceData.
Constructor Details
#initialize(types) ⇒ DtraceData
Returns a new instance of DtraceData.
12 13 14 15 16 17 |
# File 'lib/dtracedata.rb', line 12 def initialize(types) @types = types @data = [] @curraggset = nil @curragg = nil end |
Instance Attribute Details
#cpu ⇒ Object (readonly)
Returns the value of attribute cpu.
10 11 12 |
# File 'lib/dtracedata.rb', line 10 def cpu @cpu end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
8 9 10 |
# File 'lib/dtracedata.rb', line 8 def data @data end |
#flow ⇒ Object (readonly)
Returns the value of attribute flow.
10 11 12 |
# File 'lib/dtracedata.rb', line 10 def flow @flow end |
#indent ⇒ Object (readonly)
Returns the value of attribute indent.
10 11 12 |
# File 'lib/dtracedata.rb', line 10 def indent @indent end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
10 11 12 |
# File 'lib/dtracedata.rb', line 10 def prefix @prefix end |
#probe ⇒ Object (readonly)
Returns the value of attribute probe.
9 10 11 |
# File 'lib/dtracedata.rb', line 9 def probe @probe end |
Instance Method Details
#add_bufdata(buf) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/dtracedata.rb', line 55 def add_bufdata(buf) r = buf.record # buf records can be empty (trace();) if r case r.class.to_s when DtraceStackRecord.to_s add_data(r) when DtraceRecord.to_s add_data(r) when DtracePrintfRecord.to_s add_data(r) when DtraceAggData.to_s if @curragg == nil @curragg = DtraceAggregate.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
19 20 21 22 23 |
# File 'lib/dtracedata.rb', line 19 def add_data(d) if @types.length == 0 || @types.include?(d.class) @data << d end end |
#add_probedata(probedata) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/dtracedata.rb', line 42 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
32 33 34 35 36 37 38 39 40 |
# File 'lib/dtracedata.rb', line 32 def add_recdata(rec) if @curraggset add_data(@curraggset) @curraggset = nil end if rec.action == "printa" @curraggset = DtraceAggregateSet.new end end |
#finish ⇒ Object
25 26 27 28 29 30 |
# File 'lib/dtracedata.rb', line 25 def finish if @curraggset add_data(@curraggset) @curraggset = nil end end |