Class: GH::Instrumentation

Inherits:
Wrapper
  • Object
show all
Defined in:
lib/gh/instrumentation.rb

Overview

Public: This class caches responses.

Instance Attribute Summary collapse

Attributes inherited from Wrapper

#backend, #frontend, #options

Instance Method Summary collapse

Methods inherited from Wrapper

[], double_dispatch, #generate_response, #initialize, #inspect, #prefixed, #reset, wraps

Constructor Details

This class inherits a constructor from GH::Wrapper

Instance Attribute Details

#instrumenterObject

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



9
10
11
# File 'lib/gh/instrumentation.rb', line 9

def instrumenter
  @instrumenter
end

Instance Method Details

#[](key) ⇒ Object



25
26
27
# File 'lib/gh/instrumentation.rb', line 25

def [](key)
  instrument(:access, key:) { super }
end

#http(verb, url) ⇒ Object



17
18
19
# File 'lib/gh/instrumentation.rb', line 17

def http(verb, url, *)
  instrument(:http, verb:, url:) { super }
end

#load(data) ⇒ Object



21
22
23
# File 'lib/gh/instrumentation.rb', line 21

def load(data)
  instrument(:load, data:) { super }
end

#setup(backend, options) ⇒ Object



11
12
13
14
15
# File 'lib/gh/instrumentation.rb', line 11

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