Class: NewRelic::Starter::Rack
- Inherits:
-
Object
- Object
- NewRelic::Starter::Rack
- Defined in:
- lib/new_relic/starter/rack.rb
Overview
NewRelic::Starter::Rack is a Rack middleware that provides an endpoint to start the New Relic agent.
Instance Method Summary collapse
-
#call(env) ⇒ Array
Opens a latch and start the New Relic agent if the path of the request matches with the path of the endpoint.
-
#initialize(app, latch: Latch.new, path: nil) ⇒ NewRelic::Starter::Rack
constructor
Returns a new Rack which implements the Rack interface.
Constructor Details
#initialize(app, latch: Latch.new, path: nil) ⇒ NewRelic::Starter::Rack
Returns a new NewRelic::Starter::Rack which implements the Rack interface.
17 18 19 20 21 22 |
# File 'lib/new_relic/starter/rack.rb', line 17 def initialize(app, latch: Latch.new, path: nil) @app = app @latch = latch @path = path || '/_new_relic/start' @starter = Starter.new(latch) end |
Instance Method Details
#call(env) ⇒ Array
Opens a latch and start the New Relic agent if the path of the request matches with the path of the endpoint.
When the path doesn’t match, if a latch is opened, the agent is started before calling the next application.
32 33 34 35 36 37 38 39 |
# File 'lib/new_relic/starter/rack.rb', line 32 def call(env) if env['PATH_INFO'] == @path handle else @starter.start @app.call(env) end end |