Class: TraceViz::Collectors::TraceStats

Inherits:
Object
  • Object
show all
Defined in:
lib/trace_viz/collectors/trace_stats.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTraceStats

Returns a new instance of TraceStats.



8
9
10
11
12
# File 'lib/trace_viz/collectors/trace_stats.rb', line 8

def initialize
  @total_traces = 0
  @max_depth = 0
  @event_counts = Hash.new(0)
end

Instance Attribute Details

#event_countsObject (readonly)

Returns the value of attribute event_counts.



6
7
8
# File 'lib/trace_viz/collectors/trace_stats.rb', line 6

def event_counts
  @event_counts
end

#max_depthObject (readonly)

Returns the value of attribute max_depth.



6
7
8
# File 'lib/trace_viz/collectors/trace_stats.rb', line 6

def max_depth
  @max_depth
end

#total_tracesObject (readonly)

Returns the value of attribute total_traces.



6
7
8
# File 'lib/trace_viz/collectors/trace_stats.rb', line 6

def total_traces
  @total_traces
end

Instance Method Details

#update(trace_data) ⇒ Object



14
15
16
17
18
# File 'lib/trace_viz/collectors/trace_stats.rb', line 14

def update(trace_data)
  @total_traces += 1
  @max_depth = [@max_depth, trace_data.depth].max
  @event_counts[trace_data.event] += 1
end