Class: RailsPerformance::CurrentRequest
- Inherits:
-
Object
- Object
- RailsPerformance::CurrentRequest
- Defined in:
- lib/rails_performance/thread/current_request.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#ignore ⇒ Object
readonly
Returns the value of attribute ignore.
-
#record ⇒ Object
Returns the value of attribute record.
-
#request_id ⇒ Object
readonly
Returns the value of attribute request_id.
-
#tracings ⇒ Object
readonly
Returns the value of attribute tracings.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(request_id) ⇒ CurrentRequest
constructor
A new instance of CurrentRequest.
- #trace(options = {}) ⇒ Object
Constructor Details
#initialize(request_id) ⇒ CurrentRequest
Returns a new instance of CurrentRequest.
21 22 23 24 25 26 27 |
# File 'lib/rails_performance/thread/current_request.rb', line 21 def initialize(request_id) @request_id = request_id @tracings = [] @ignore = Set.new @data = nil @record = nil end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
4 5 6 |
# File 'lib/rails_performance/thread/current_request.rb', line 4 def data @data end |
#ignore ⇒ Object (readonly)
Returns the value of attribute ignore.
3 4 5 |
# File 'lib/rails_performance/thread/current_request.rb', line 3 def ignore @ignore end |
#record ⇒ Object
Returns the value of attribute record.
5 6 7 |
# File 'lib/rails_performance/thread/current_request.rb', line 5 def record @record end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
3 4 5 |
# File 'lib/rails_performance/thread/current_request.rb', line 3 def request_id @request_id end |
#tracings ⇒ Object (readonly)
Returns the value of attribute tracings.
3 4 5 |
# File 'lib/rails_performance/thread/current_request.rb', line 3 def tracings @tracings end |
Class Method Details
.cleanup ⇒ Object
15 16 17 18 19 |
# File 'lib/rails_performance/thread/current_request.rb', line 15 def self.cleanup RailsPerformance.log "----------------------------------------------------> CurrentRequest.cleanup !!!!!!!!!!!! -------------------------\n\n" RailsPerformance.skip = false Thread.current[:rp_current_request] = nil end |
.current ⇒ Object
11 12 13 |
# File 'lib/rails_performance/thread/current_request.rb', line 11 def self.current CurrentRequest.init end |
.init ⇒ Object
7 8 9 |
# File 'lib/rails_performance/thread/current_request.rb', line 7 def self.init Thread.current[:rp_current_request] ||= CurrentRequest.new(SecureRandom.hex(16)) end |
Instance Method Details
#trace(options = {}) ⇒ Object
29 30 31 |
# File 'lib/rails_performance/thread/current_request.rb', line 29 def trace( = {}) @tracings << .merge(time: Time.current.to_i) end |