Module: ScoutApm::Tracer

Defined in:
lib/scout_apm/tracer.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



11
12
13
# File 'lib/scout_apm/tracer.rb', line 11

def self.included(klass)
  klass.extend ClassMethods
end

.instrument(type, name, options = {}) ⇒ Object

Type: the Layer type - “View” or similar Name: specific name - “users/_gravatar”. The object must respond to “#to_s”. This allows us to be more efficient - in most cases, the metric name isn’t needed unless we are processing a slow transaction. A Block: The code to be instrumented

Options:

  • :ignore_children - will not instrument any method calls beneath this call. Example use case: InfluxDB uses Net::HTTP, which is instrumented. However, we can provide more specific data if we know we’re doing an influx call, so we’d rather just instrument the Influx call and ignore Net::HTTP. when rendering the transaction tree in the UI.

  • :desc - Additional capture, SQL, or HTTP url or similar

  • :scope - set to true if you want to make this layer a subscope



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/scout_apm/tracer.rb', line 24

def self.instrument(type, name, options={}) # Takes a block
  layer = ScoutApm::Layer.new(type, name)
  layer.desc = options[:desc] if options[:desc]
  layer.subscopable!          if options[:scope]

  req = ScoutApm::RequestManager.lookup
  req.start_layer(layer)
  req.ignore_children! if options[:ignore_children]

  begin
    yield
  ensure
    req.acknowledge_children! if options[:ignore_children]
    req.stop_layer
  end
end