Class: BWAPI::Response::Performance
- Inherits:
-
Faraday::Response::Middleware
- Object
- Faraday::Response::Middleware
- BWAPI::Response::Performance
- Defined in:
- lib/bwapi/response/performance.rb
Overview
Brandwatch response middleware to monitor performance
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, client) ⇒ Performance
constructor
A new instance of Performance.
- #logger ⇒ Object
- #on_complete(_env) ⇒ Object
Constructor Details
#initialize(app, client) ⇒ Performance
Returns a new instance of Performance.
8 9 10 11 |
# File 'lib/bwapi/response/performance.rb', line 8 def initialize(app, client) super(app) @client = client end |
Instance Method Details
#call(env) ⇒ Object
20 21 22 23 24 |
# File 'lib/bwapi/response/performance.rb', line 20 def call(env) @recording = ("#{env.method}#{env.url.path}").gsub!('/', '_') Allotment.start(@recording) super end |
#logger ⇒ Object
13 14 15 16 17 18 |
# File 'lib/bwapi/response/performance.rb', line 13 def logger @logger = @client.logger || begin require 'logger' ::Logger.new(STDOUT) end end |
#on_complete(_env) ⇒ Object
26 27 28 |
# File 'lib/bwapi/response/performance.rb', line 26 def on_complete(_env) logger.info "Response time: #{Allotment.stop(@recording)} seconds" end |