Class: Lens::Trace
- Inherits:
-
Object
- Object
- Lens::Trace
- Defined in:
- lib/lens/trace.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add(event) ⇒ Object
- #complete(event) ⇒ Object
-
#initialize(id) ⇒ Trace
constructor
A new instance of Trace.
Constructor Details
#initialize(id) ⇒ Trace
Returns a new instance of Trace.
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/lens/trace.rb', line 3 def initialize(id) @id = id @data = [] @gc_statistics = Lens::GC.new @gc_statistics.enable @allocations_data = Lens::AllocationsData.new @allocations_data.enable if Lens.configuration.with_memory_usage? end |
Class Method Details
.present? ⇒ Boolean
52 53 54 |
# File 'lib/lens/trace.rb', line 52 def present? current.present? end |
Instance Method Details
#add(event) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/lens/trace.rb', line 14 def add(event) @data.push event.payload.merge( etype: event.name, eduration: event.duration, estart: event.time.to_f, efinish: event.end.to_f ) end |
#complete(event) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/lens/trace.rb', line 23 def complete(event) formatter = Lens::EventFormatter.new( event, @data, @gc_statistics.total_time, @allocations_data ) formatted_data = formatter.json_formatted send(formatted_data) Thread.current[:__lens_trace] = nil end |