Class: DashAnalyzer::Base
- Inherits:
-
Object
- Object
- DashAnalyzer::Base
- Defined in:
- lib/dash_analyzer/base.rb
Overview
Hooks up dash to your db Implement in as a middleware like so:
class MyApp < DashAnalyzer::Base
Fiveruns::Dash.register_recipe :testpack, :url => 'http://example.org' do |recipe|
Fiveruns::Dash.logger.info 'REGISTERING ACTIONPACK RECIPE'
recipe.time :response_time, :method => 'DashAnalyzer::Base#call', :mark => true
recipe.time :another_response_time, :method => 'DashAnalyzer::Base#call', :mark => true
end
def initialize(*)
@recipes = [{:name => :testpack, :url => 'http://example.org'}]
super
end
end
Direct Known Subclasses
Instance Attribute Summary collapse
-
#db ⇒ Object
Returns the value of attribute db.
-
#logger ⇒ Object
Returns the value of attribute logger.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, dash_interval = 60) ⇒ Base
constructor
A new instance of Base.
- #startup_dash(interval = 60) ⇒ Object
Constructor Details
#initialize(app, dash_interval = 60) ⇒ Base
Returns a new instance of Base.
21 22 23 24 25 26 27 28 |
# File 'lib/dash_analyzer/base.rb', line 21 def initialize(app, dash_interval=60) @db = AbstractAnalyzer.const_get("DB") @logger = AbstractAnalyzer.const_get("LOGGER") startup_dash(dash_interval) @app = app end |
Instance Attribute Details
#db ⇒ Object
Returns the value of attribute db.
19 20 21 |
# File 'lib/dash_analyzer/base.rb', line 19 def db @db end |
#logger ⇒ Object
Returns the value of attribute logger.
19 20 21 |
# File 'lib/dash_analyzer/base.rb', line 19 def logger @logger end |
Instance Method Details
#call(env) ⇒ Object
30 31 32 |
# File 'lib/dash_analyzer/base.rb', line 30 def call(env) @app.call(env) end |
#startup_dash(interval = 60) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/dash_analyzer/base.rb', line 34 def startup_dash(interval = 60) return if Fiveruns::Dash.session.reporter.started? Fiveruns::Dash.session.reset Fiveruns::Dash.logger = @logger ENV['DASH_UPDATE'] = "mongo://db" Fiveruns::Dash.configure do |config| config.db = db @recipes.each do |r| config.add_recipe r[:name], r[:url] end end Fiveruns::Dash.session.interval = interval Fiveruns::Dash.session.start end |