Class: Insight::App
Defined Under Namespace
Classes: SecurityError
Constant Summary collapse
- INSIGHT_ROOT =
"/__insight__"
- INSIGHT_REGEX =
%r{^#{INSIGHT_ROOT}}
- VERSION =
"0.4.4"
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#panels ⇒ Object
Returns the value of attribute panels.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}, &block) ⇒ App
constructor
A new instance of App.
- #reset(new_options = nil) ⇒ Object
Methods included from Options
Constructor Details
#initialize(app, options = {}, &block) ⇒ App
Returns a new instance of App.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/insight/app.rb', line 31 def initialize(app, = {}, &block) @base_app = app @panels = [] instance_eval(&block) if block_given? @logger = Logger.new(read_option(:log_level), read_option(:log_path)) Thread.current['insight.logger'] = @logger build_normal_stack build_debug_stack if [:on_initialize] [:on_initialize].call(self) end end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
45 46 47 |
# File 'lib/insight/app.rb', line 45 def logger @logger end |
#panels ⇒ Object
Returns the value of attribute panels.
46 47 48 |
# File 'lib/insight/app.rb', line 46 def panels @panels end |
Instance Method Details
#call(env) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/insight/app.rb', line 48 def call(env) env.replace @default_options.merge(env) @env = env @original_request = Rack::Request.new(@env) env['insight.logger'] = @logger Thread.current['insight.logger'] = @logger if insight_active? Insight.enable env["insight.panels"] = [] result = @debug_stack.call(env) result else @normal_stack.call(env) end end |
#reset(new_options = nil) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/insight/app.rb', line 66 def reset(=nil) () Insight::Instrumentation::ClassProbe::all_probes.each do |probe| probe.clear_collectors end Insight::Instrumentation::InstanceProbe::all_probes.each do |probe| probe.clear_collectors end Insight::Instrumentation::PackageDefinition.clear_collectors build_debug_stack end |