Sha256: 828338f7c22f73cf95bda8aeb430f28a707afed7c0aae7a0955434d560b97c00
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
class LHC::Monitoring < LHC::Interceptor # Options forwarded to the monitoring FORWARDED_OPTIONS = { monitoring_key: :key, } include ActiveSupport::Configurable config_accessor :statsd def after_request(request) return unless statsd key = "#{key(request)}.count" LHC::Monitoring.statsd.count(key, 1) end def after_response(response) return unless statsd key = key(response) LHC::Monitoring.statsd.timing("#{key}.time", response.time) if response.success? key += response.timeout? ? '.timeout' : ".#{response.code}" LHC::Monitoring.statsd.count(key, 1) end private def key(target) request = target.is_a?(LHC::Request) ? target : target.request key = options(request.options)[:key] return key if key.present? key = [ 'lhc', Rails.application.class.parent_name.underscore, Rails.env, URI.parse(request.url).host.gsub(/\./, '_'), request.method ] key.join('.') end def options(input = {}) options = {} FORWARDED_OPTIONS.each do |k, v| options[v] = input[k] if input.key?(k) end options end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lhc-core-interceptors-2.0.0 | lib/lhc-core-interceptors/monitoring.rb |
lhc-core-interceptors-1.0.0 | lib/lhc-core-interceptors/monitoring.rb |