Sha256: d870eff201a73b9394ea07ab6eec0701a0d71dac698503b069df4c0fbb59f825
Contents?: true
Size: 694 Bytes
Versions: 1
Compression:
Stored size: 694 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 ActiveSupport::Notifications.subscribe('request.faraday') do |*args| event = ActiveSupport::Notifications::Event.new(*args) Traxor::Faraday.record(event) end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
traxor-0.1.18 | lib/traxor/faraday.rb |