Class: NewrelicGvl::Rack::Middleware
- Inherits:
-
Object
- Object
- NewrelicGvl::Rack::Middleware
- Defined in:
- lib/newrelic_gvl/rack/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
6 7 8 |
# File 'lib/newrelic_gvl/rack/middleware.rb', line 6 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/newrelic_gvl/rack/middleware.rb', line 10 def call(env) before = GVLTools::LocalTimer.monotonic_time @app.call(env).tap do |response| wait_in_ms = (GVLTools::LocalTimer.monotonic_time - before) / 1_000_000.0 NewRelic::Agent.add_custom_attributes({gvl_wait: wait_in_ms}) end end |