Class: NewRelic::Rack::AgentHooks
- Inherits:
-
Object
- Object
- NewRelic::Rack::AgentHooks
- Defined in:
- lib/new_relic/rack/agent_hooks.rb
Constant Summary collapse
- FIRED_FORMATS =
{ :before_call => "newrelic.agent_hooks_before_fired", :after_call => "newrelic.agent_hooks_after_fired" }
Instance Method Summary collapse
-
#call(env) ⇒ Object
method required by Rack interface [status, headers, response].
- #events ⇒ Object
-
#initialize(app, options = {}) ⇒ AgentHooks
constructor
A new instance of AgentHooks.
- #notify(event, env, *args) ⇒ Object
Constructor Details
#initialize(app, options = {}) ⇒ AgentHooks
Returns a new instance of AgentHooks.
9 10 11 |
# File 'lib/new_relic/rack/agent_hooks.rb', line 9 def initialize(app, = {}) @app = app end |
Instance Method Details
#call(env) ⇒ Object
method required by Rack interface
- status, headers, response
20 21 22 23 24 25 |
# File 'lib/new_relic/rack/agent_hooks.rb', line 20 def call(env) notify(:before_call, env) result = @app.call(env) notify(:after_call, env, result) result end |
#events ⇒ Object
33 34 35 |
# File 'lib/new_relic/rack/agent_hooks.rb', line 33 def events NewRelic::Agent.instance.events end |
#notify(event, env, *args) ⇒ Object
27 28 29 30 31 |
# File 'lib/new_relic/rack/agent_hooks.rb', line 27 def notify(event, env, *args) key = FIRED_FORMATS[event] events.notify(event, *([env] + args)) unless env[key] env[key] = true end |