Class: RestfulResource::InstrumentationMiddleware
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- RestfulResource::InstrumentationMiddleware
- Defined in:
- lib/restful_resource/faraday_instrumentation_middleware.rb
Overview
Faraday middleware that instruments requests via ActiveSupport::Notifications. Replaces FaradayMiddleware::Instrumentation, which the faraday_middleware gem does not ship a Faraday 2 compatible release of.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, name: 'request.faraday') ⇒ InstrumentationMiddleware
constructor
A new instance of InstrumentationMiddleware.
Constructor Details
#initialize(app, name: 'request.faraday') ⇒ InstrumentationMiddleware
Returns a new instance of InstrumentationMiddleware.
9 10 11 12 |
# File 'lib/restful_resource/faraday_instrumentation_middleware.rb', line 9 def initialize(app, name: 'request.faraday') super(app) @name = name end |
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 18 |
# File 'lib/restful_resource/faraday_instrumentation_middleware.rb', line 14 def call(env) ActiveSupport::Notifications.instrument(@name, env) do @app.call(env) end end |