Class: RailsTracepointStack::TraceSession

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeTraceSession

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

#errorObject

Returns the value of attribute error.



10
11
12
# File 'lib/rails_tracepoint_stack/trace_session.rb', line 10

def error
  @error
end

#filtered_countObject

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

#resultObject

Returns the value of attribute result.



10
11
12
# File 'lib/rails_tracepoint_stack/trace_session.rb', line 10

def result
  @result
end

#tracesObject (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

Parameters:

  • value

    the value to set the attribute truncated to.



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_jsonObject



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

Returns:

  • (Boolean)


23
24
25
# File 'lib/rails_tracepoint_stack/trace_session.rb', line 23

def empty?
  @traces.empty?
end

#summaryObject



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_treeObject 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.

Returns:

  • (Boolean)


29
30
31
# File 'lib/rails_tracepoint_stack/trace_session.rb', line 29

def truncated?
  @truncated
end