Sha256: ef627afd80eed1b76813343bfb9250a6555a60e93e5e90768f385d41d90ce66f
Contents?: true
Size: 761 Bytes
Versions: 2
Compression:
Stored size: 761 Bytes
Contents
# frozen_string_literal: true require 'active_support/notifications' module Traxor module Faraday DURATION_METRIC = 'faraday.request.duration' COUNT_METRIC = 'faraday.request.count' def self.record(event) url = event.payload[:url] duration = (event.duration || 0.0).to_f tags = { faraday_host: url.host, faraday_method: event.payload[:method] } Metric.count COUNT_METRIC, 1, tags Metric.measure DURATION_METRIC, "#{duration.round(2)}ms", tags if duration.positive? end end end if Traxor.enabled? && Traxor.scopes.include?(:faraday) ActiveSupport::Notifications.subscribe('request.faraday') do |*args| event = ActiveSupport::Notifications::Event.new(*args) Traxor::Faraday.record(event) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
traxor-0.1.20 | lib/traxor/faraday.rb |
traxor-0.1.19 | lib/traxor/faraday.rb |