Class: Lens::Trace
- Inherits:
-
Object
- Object
- Lens::Trace
- Defined in:
- lib/lens/trace.rb
Instance Attribute Summary collapse
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
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.
15 16 17 18 19 |
# File 'lib/lens/trace.rb', line 15 def initialize(id) @id = id @events = [] @duration = 0 end |
Instance Attribute Details
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
5 6 7 |
# File 'lib/lens/trace.rb', line 5 def duration @duration end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/lens/trace.rb', line 5 def id @id end |
Class Method Details
.create(id) ⇒ Object
11 12 13 |
# File 'lib/lens/trace.rb', line 11 def self.create(id) Thread.current[:__lens_trace] = new(id) end |
.current ⇒ Object
7 8 9 |
# File 'lib/lens/trace.rb', line 7 def self.current Thread.current[:__lens_trace] end |
Instance Method Details
#add(event) ⇒ Object
21 22 23 |
# File 'lib/lens/trace.rb', line 21 def add(event) @events.push event end |
#complete(event) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/lens/trace.rb', line 25 def complete(event) @duration = event.duration Rails.logger.info "all [LENS] >>> #{@events}" Rails.logger.info "last [LENS] >>> #{event}" Thread.current[:__lens_trace] = nil end |