Class: ActionCost::Data
- Inherits:
-
Object
- Object
- ActionCost::Data
- Defined in:
- lib/action_cost/middleware.rb
Overview
ActionCost data store
Instance Attribute Summary collapse
-
#request_stats ⇒ Object
readonly
Returns the value of attribute request_stats.
-
#stats_collector ⇒ Object
readonly
Returns the value of attribute stats_collector.
Instance Method Summary collapse
- #accumulated_stats ⇒ Object
- #end_request ⇒ Object
-
#initialize ⇒ Data
constructor
A new instance of Data.
- #push_sql_parser(parser) ⇒ Object
- #start_request(env) ⇒ Object
Constructor Details
#initialize ⇒ Data
Returns a new instance of Data.
7 8 9 10 11 12 |
# File 'lib/action_cost/middleware.rb', line 7 def initialize # Per process storage @stats_collector = ActionCost::StatsCollector.new # Per HTTP request storage @request_stats = nil end |
Instance Attribute Details
#request_stats ⇒ Object (readonly)
Returns the value of attribute request_stats.
5 6 7 |
# File 'lib/action_cost/middleware.rb', line 5 def request_stats @request_stats end |
#stats_collector ⇒ Object (readonly)
Returns the value of attribute stats_collector.
5 6 7 |
# File 'lib/action_cost/middleware.rb', line 5 def stats_collector @stats_collector end |
Instance Method Details
#accumulated_stats ⇒ Object
30 31 32 33 |
# File 'lib/action_cost/middleware.rb', line 30 def accumulated_stats return unless @stats_collector @stats_collector.data end |
#end_request ⇒ Object
18 19 20 21 22 23 |
# File 'lib/action_cost/middleware.rb', line 18 def end_request return unless @request_stats @request_stats.close @stats_collector.push(@request_stats) @request_stats = nil end |
#push_sql_parser(parser) ⇒ Object
25 26 27 28 |
# File 'lib/action_cost/middleware.rb', line 25 def push_sql_parser(parser) return unless @request_stats @request_stats.push(parser) end |
#start_request(env) ⇒ Object
14 15 16 |
# File 'lib/action_cost/middleware.rb', line 14 def start_request(env) @request_stats = ActionCost::RequestStats.new(env) end |