Class: Rack::PerftoolsProfiler
- Inherits:
-
Object
- Object
- Rack::PerftoolsProfiler
- Includes:
- Utils
- Defined in:
- lib/rack/contrib/perftools_profiler.rb
Constant Summary collapse
- PRINTER_CONTENT_TYPE =
{ :text => 'text/plain', :gif => 'image/gif', :pdf => 'application/pdf' }
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
- #call_app(env) ⇒ Object
- #force_stop ⇒ Object
-
#initialize(app, options = {}) ⇒ PerftoolsProfiler
constructor
A new instance of PerftoolsProfiler.
- #profiler_data_response(profiling_data) ⇒ Object
Constructor Details
#initialize(app, options = {}) ⇒ PerftoolsProfiler
Returns a new instance of PerftoolsProfiler.
96 97 98 99 |
# File 'lib/rack/contrib/perftools_profiler.rb', line 96 def initialize(app, = {}) @app = app @profiler = Profiler.new(@app, .clone) end |
Class Method Details
.clear_data ⇒ Object
86 87 88 |
# File 'lib/rack/contrib/perftools_profiler.rb', line 86 def self.clear_data Profiler.clear_data end |
.with_profiling_off(app, options = {}) ⇒ Object
90 91 92 93 94 |
# File 'lib/rack/contrib/perftools_profiler.rb', line 90 def self.with_profiling_off(app, = {}) instance = self.new(app, ) instance.force_stop instance end |
Instance Method Details
#call(env) ⇒ Object
101 102 103 104 105 |
# File 'lib/rack/contrib/perftools_profiler.rb', line 101 def call(env) action = Action.for_env(env.clone, @profiler, self) action.act action.response end |
#call_app(env) ⇒ Object
107 108 109 |
# File 'lib/rack/contrib/perftools_profiler.rb', line 107 def call_app(env) @app.call(env) end |
#force_stop ⇒ Object
111 112 113 |
# File 'lib/rack/contrib/perftools_profiler.rb', line 111 def force_stop @profiler.stop end |
#profiler_data_response(profiling_data) ⇒ Object
115 116 117 118 119 120 121 122 |
# File 'lib/rack/contrib/perftools_profiler.rb', line 115 def profiler_data_response(profiling_data) format, body = profiling_data if format==:none [404, {'Content-Type' => 'text/plain'}, ['No profiling data available.']] else [200, headers(format, body), Array(body)] end end |