class ScoutApm::LimitedLayer

A LimitedLayer is a lossy-compression approach to fall back on once we max out the number of detailed layer objects we store. See LayerChildrenSet for the logic on when that change over happens

QUESTION: What do we do if we attempt to merge an item that has children?

Attributes

type[R]

Public Class Methods

new(type) click to toggle source
# File lib/scout_apm/limited_layer.rb, line 10
def initialize(type)
  @type = type

  @total_call_time = 0
  @total_exclusive_time = 0
  @total_allocations = 0
  @total_exclusive_allocations = 0
  @total_layers = 0
end

Public Instance Methods

absorb(layer) click to toggle source
# File lib/scout_apm/limited_layer.rb, line 20
def absorb(layer)
  @total_layers += 1

  @total_call_time += layer.total_call_time
  @total_exclusive_time += layer.total_exclusive_time

  @total_allocations += layer.total_allocations
  @total_exclusive_allocations += layer.total_exclusive_allocations
end
add_child() click to toggle source

Many methods don't make any sense on a limited layer. Raise errors # aggressively for now to detect mistaken calls #

# File lib/scout_apm/limited_layer.rb, line 94
def add_child
  raise "Should never call add_child on a limited_layer"
end
annotate_layer(*) click to toggle source
# File lib/scout_apm/limited_layer.rb, line 110
def annotate_layer(*)
  raise "Should never call annotate_layer on a limited_layer"
end
annotations() click to toggle source
# File lib/scout_apm/limited_layer.rb, line 61
def annotations
  nil
end
backtrace() click to toggle source
# File lib/scout_apm/limited_layer.rb, line 84
def backtrace
  nil
end
caller_array() click to toggle source
# File lib/scout_apm/limited_layer.rb, line 122
def caller_array
  raise "Should never call caller_array on a limited_layer"
end
capture_backtrace!() click to toggle source
# File lib/scout_apm/limited_layer.rb, line 118
def capture_backtrace!
  raise "Should never call capture_backtrace on a limited_layer"
end
children() click to toggle source
# File lib/scout_apm/limited_layer.rb, line 57
def children
  Set.new
end
count() click to toggle source
# File lib/scout_apm/limited_layer.rb, line 46
def count
  @total_layers
end
desc() click to toggle source
# File lib/scout_apm/limited_layer.rb, line 80
def desc
  nil
end
desc=(*) click to toggle source
# File lib/scout_apm/limited_layer.rb, line 106
def desc=(*)
  raise "Should never call desc on a limited_layer"
end
legacy_metric_name() click to toggle source

This is the old style name. This function is used for now, but should be removed, and the new type & name split should be enforced through the app.

# File lib/scout_apm/limited_layer.rb, line 53
def legacy_metric_name
  "#{type}/Limited"
end
limited?() click to toggle source
# File lib/scout_apm/limited_layer.rb, line 69
def limited?
  true
end
record_allocations!() click to toggle source
# File lib/scout_apm/limited_layer.rb, line 102
def record_allocations!
  raise "Should never call record_allocations! on a limited_layer"
end
record_stop_time!(*) click to toggle source
# File lib/scout_apm/limited_layer.rb, line 98
def record_stop_time!(*)
  raise "Should never call record_stop_time! on a limited_layer"
end
subscopable!() click to toggle source
# File lib/scout_apm/limited_layer.rb, line 114
def subscopable!
  raise "Should never call subscopable! on a limited_layer"
end
subscopable?() click to toggle source

Stub out some methods with static default values #

# File lib/scout_apm/limited_layer.rb, line 76
def subscopable?
  false
end
to_s() click to toggle source
# File lib/scout_apm/limited_layer.rb, line 65
def to_s
  "<LimitedLayer type=#{type} count=#{count}>"
end
total_allocations() click to toggle source
# File lib/scout_apm/limited_layer.rb, line 38
def total_allocations
  @total_allocations
end
total_call_time() click to toggle source
# File lib/scout_apm/limited_layer.rb, line 30
def total_call_time
  @total_call_time
end
total_exclusive_allocations() click to toggle source
# File lib/scout_apm/limited_layer.rb, line 42
def total_exclusive_allocations
  @total_exclusive_allocations
end
total_exclusive_time() click to toggle source
# File lib/scout_apm/limited_layer.rb, line 34
def total_exclusive_time
  @total_exclusive_time
end