Sha256: dbd3b0901fef47bac817bcc9864b46db3bc139aabae71dd11566662839ab0f46
Contents?: true
Size: 864 Bytes
Versions: 19
Compression:
Stored size: 864 Bytes
Contents
# frozen_string_literal: true module OmniAI # Used for logging. class Instrumentation # @param logger [Logger] def initialize(logger:) @logger = logger end # @param name [String] # @param payload [Hash] # @option payload [Exception] :error def instrument(name, payload = {}) error = payload[:error] return unless error @logger.error("#{name}: #{error.message}") end # @param payload [Hash] # @option payload [HTTP::Request] :request def start(_, payload) request = payload[:request] @logger.info("#{request.verb.upcase} #{request.uri}") end # @param payload [Hash] # @option payload [HTTP::Response] :response def finish(_, payload) response = payload[:response] @logger.info("#{response.status.code} #{response.status.reason}") end end end
Version data entries
19 entries across 19 versions & 1 rubygems