Class: TraceViz::Collectors::TraceStats
- Inherits:
-
Object
- Object
- TraceViz::Collectors::TraceStats
- Defined in:
- lib/trace_viz/collectors/trace_stats.rb
Instance Attribute Summary collapse
-
#event_counts ⇒ Object
readonly
Returns the value of attribute event_counts.
-
#max_depth ⇒ Object
readonly
Returns the value of attribute max_depth.
-
#total_traces ⇒ Object
readonly
Returns the value of attribute total_traces.
Instance Method Summary collapse
-
#initialize ⇒ TraceStats
constructor
A new instance of TraceStats.
- #update(trace_data) ⇒ Object
Constructor Details
#initialize ⇒ TraceStats
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_counts ⇒ Object (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_depth ⇒ Object (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_traces ⇒ Object (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 |