class GH::Instrumentation

Public: This class caches responses.

Attributes

instrumenter[RW]

Public: Get/set instrumenter to use. Compatible with ActiveSupport::Notification and Travis::EventLogger.

Public Instance Methods

[](key) click to toggle source
Calls superclass method
# File lib/gh/instrumentation.rb, line 23
def [](key)
  instrument(:access, :key => key) { super }
end
http(verb, url, *) click to toggle source
Calls superclass method
# File lib/gh/instrumentation.rb, line 15
def http(verb, url, *)
  instrument(:http, :verb => verb, :url => url) { super }
end
load(data) click to toggle source
Calls superclass method
# File lib/gh/instrumentation.rb, line 19
def load(data)
  instrument(:load, :data => data) { super }
end
setup(backend, options) click to toggle source
Calls superclass method
# File lib/gh/instrumentation.rb, line 9
def setup(backend, options)
  self.instrumenter ||= Travis::EventLogger.method(:notify)              if defined? Travis::EventLogger
  self.instrumenter ||= ActiveSupport::Notifications.method(:instrument) if defined? ActiveSupport::Notifications
  super
end

Private Instance Methods

instrument(type, payload = {}) { || ... } click to toggle source
# File lib/gh/instrumentation.rb, line 29
def instrument(type, payload = {})
  return yield unless instrumenter
  result = nil
  instrumenter.call("#{type}.gh", payload.merge(:gh => frontend)) { result = yield }
  return result
end