Class: VoyageAI::Instrumentation
- Inherits:
-
Object
- Object
- VoyageAI::Instrumentation
- Defined in:
- lib/voyageai/instrumentation.rb
Overview
Used for logging via HTTP.
Instance Method Summary collapse
- #finish(_, payload) ⇒ Object
-
#initialize(logger:) ⇒ Instrumentation
constructor
A new instance of Instrumentation.
- #instrument(name, payload = {}) ⇒ Object
- #start(_, payload) ⇒ Object
Constructor Details
#initialize(logger:) ⇒ Instrumentation
Returns a new instance of Instrumentation.
7 8 9 |
# File 'lib/voyageai/instrumentation.rb', line 7 def initialize(logger:) @logger = logger end |
Instance Method Details
#finish(_, payload) ⇒ Object
30 31 32 33 |
# File 'lib/voyageai/instrumentation.rb', line 30 def finish(_, payload) response = payload[:response] @logger.info("#{response.status.code} #{response.status.reason}") end |
#instrument(name, payload = {}) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/voyageai/instrumentation.rb', line 14 def instrument(name, payload = {}) error = payload[:error] return unless error @logger.error("#{name}: #{error.}") end |
#start(_, payload) ⇒ Object
23 24 25 26 |
# File 'lib/voyageai/instrumentation.rb', line 23 def start(_, payload) request = payload[:request] @logger.info("#{request.verb.upcase} #{request.uri}") end |