Class: Alchemrest::FaradayMiddleware::ExternalApiInstrumentation
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Alchemrest::FaradayMiddleware::ExternalApiInstrumentation
- Defined in:
- lib/alchemrest/faraday_middleware/external_api_instrumentation.rb
Instance Attribute Summary collapse
-
#external_service ⇒ Object
readonly
Returns the value of attribute external_service.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ ExternalApiInstrumentation
constructor
A new instance of ExternalApiInstrumentation.
- #name ⇒ Object
Constructor Details
#initialize(app, options = {}) ⇒ ExternalApiInstrumentation
Returns a new instance of ExternalApiInstrumentation.
8 9 10 11 |
# File 'lib/alchemrest/faraday_middleware/external_api_instrumentation.rb', line 8 def initialize(app, = {}) super(app) @external_service = .fetch(:external_service) end |
Instance Attribute Details
#external_service ⇒ Object (readonly)
Returns the value of attribute external_service.
6 7 8 |
# File 'lib/alchemrest/faraday_middleware/external_api_instrumentation.rb', line 6 def external_service @external_service end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 |
# File 'lib/alchemrest/faraday_middleware/external_api_instrumentation.rb', line 13 def call(env) ::ActiveSupport::Notifications.instrument(name, env: env, external_service: external_service) do @app.call(env) end end |
#name ⇒ Object
19 20 21 |
# File 'lib/alchemrest/faraday_middleware/external_api_instrumentation.rb', line 19 def name "#{external_service}_api_request" end |