Class: LHC::Monitoring

Inherits:
Interceptor
  • Object
show all
Includes:
ActiveSupport::Configurable
Defined in:
lib/lhc-core-interceptors/monitoring.rb

Constant Summary collapse

FORWARDED_OPTIONS =

Options forwarded to the monitoring

{
  monitoring_key: :key
}

Instance Method Summary collapse

Instance Method Details

#after_request(request) ⇒ Object



17
18
19
20
21
# File 'lib/lhc-core-interceptors/monitoring.rb', line 17

def after_request(request)
  return unless statsd
  LHC::Monitoring.statsd.count("#{key(request)}.count", 1)
  LHC::Monitoring.statsd.count("#{key(request)}.after_request", 1)
end

#after_response(response) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/lhc-core-interceptors/monitoring.rb', line 23

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

#before_request(request) ⇒ Object



12
13
14
15
# File 'lib/lhc-core-interceptors/monitoring.rb', line 12

def before_request(request)
  return unless statsd
  LHC::Monitoring.statsd.count("#{key(request)}.before_request", 1)
end