Class: RailsTracepointStack::TraceSession
- Inherits:
-
Object
- Object
- RailsTracepointStack::TraceSession
- Defined in:
- lib/rails_tracepoint_stack/trace_session.rb
Overview
The traces gathered by one capture, plus whatever the traced block itself produced.
Instance Attribute Summary collapse
-
#error ⇒ Object
Returns the value of attribute error.
-
#filtered_count ⇒ Object
Returns the value of attribute filtered_count.
-
#result ⇒ Object
Returns the value of attribute result.
-
#traces ⇒ Object
readonly
Returns the value of attribute traces.
-
#truncated ⇒ Object
writeonly
Sets the attribute truncated.
Instance Method Summary collapse
- #add(record) ⇒ Object
- #as_json ⇒ Object
- #empty? ⇒ Boolean
-
#initialize ⇒ TraceSession
constructor
A new instance of TraceSession.
- #summary ⇒ Object
- #to_json(*args) ⇒ Object
- #to_tree ⇒ Object (also: #to_s)
-
#truncated? ⇒ Boolean
True when a limit stopped the collection, so the traces are a prefix of what actually ran rather than the whole story.
Constructor Details
#initialize ⇒ TraceSession
Returns a new instance of TraceSession.
13 14 15 16 17 |
# File 'lib/rails_tracepoint_stack/trace_session.rb', line 13 def initialize @traces = [] @truncated = false @filtered_count = 0 end |
Instance Attribute Details
#error ⇒ Object
Returns the value of attribute error.
10 11 12 |
# File 'lib/rails_tracepoint_stack/trace_session.rb', line 10 def error @error end |
#filtered_count ⇒ Object
Returns the value of attribute filtered_count.
10 11 12 |
# File 'lib/rails_tracepoint_stack/trace_session.rb', line 10 def filtered_count @filtered_count end |
#result ⇒ Object
Returns the value of attribute result.
10 11 12 |
# File 'lib/rails_tracepoint_stack/trace_session.rb', line 10 def result @result end |
#traces ⇒ Object (readonly)
Returns the value of attribute traces.
9 10 11 |
# File 'lib/rails_tracepoint_stack/trace_session.rb', line 9 def traces @traces end |
#truncated=(value) ⇒ Object (writeonly)
Sets the attribute truncated
11 12 13 |
# File 'lib/rails_tracepoint_stack/trace_session.rb', line 11 def truncated=(value) @truncated = value end |
Instance Method Details
#add(record) ⇒ Object
19 20 21 |
# File 'lib/rails_tracepoint_stack/trace_session.rb', line 19 def add(record) @traces << record end |
#as_json ⇒ Object
42 43 44 45 46 47 |
# File 'lib/rails_tracepoint_stack/trace_session.rb', line 42 def as_json { summary: summary, traces: traces.map { |record| entry_for(record) } } end |
#empty? ⇒ Boolean
23 24 25 |
# File 'lib/rails_tracepoint_stack/trace_session.rb', line 23 def empty? @traces.empty? end |
#summary ⇒ Object
38 39 40 |
# File 'lib/rails_tracepoint_stack/trace_session.rb', line 38 def summary RailsTracepointStack::Renderer::Summary.call(self) end |
#to_json(*args) ⇒ Object
49 50 51 |
# File 'lib/rails_tracepoint_stack/trace_session.rb', line 49 def to_json(*args) JSON.generate(as_json, *args) end |
#to_tree ⇒ Object Also known as: to_s
33 34 35 |
# File 'lib/rails_tracepoint_stack/trace_session.rb', line 33 def to_tree RailsTracepointStack::Renderer::Tree.call(self) end |
#truncated? ⇒ Boolean
True when a limit stopped the collection, so the traces are a prefix of what actually ran rather than the whole story.
29 30 31 |
# File 'lib/rails_tracepoint_stack/trace_session.rb', line 29 def truncated? @truncated end |