Class: ScoutApm::LimitedLayer

Inherits:
Object
  • Object
show all
Defined in:
lib/scout_apm/limited_layer.rb

Overview

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?

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ LimitedLayer

Returns a new instance of LimitedLayer.



10
11
12
13
14
15
16
17
18
# 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

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



8
9
10
# File 'lib/scout_apm/limited_layer.rb', line 8

def type
  @type
end

Instance Method Details

#absorb(layer) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/scout_apm/limited_layer.rb', line 20

def absorb(layer)
  @total_layers += 1

  @total_call_time += layer.total_call_time
  # For limited layers, exclusive time should equal total time since limited layers
  # report no children. As such, we need to consider all absorbed time as exclusive.
  @total_exclusive_time += layer.total_call_time

  @total_allocations += layer.total_allocations
  # Same logic applies to allocations
  @total_exclusive_allocations += layer.total_allocations
end

#add_childObject

Many methods don’t make any sense on a limited layer. Raise errors #

aggressively for now to detect mistaken calls                      #


97
98
99
# File 'lib/scout_apm/limited_layer.rb', line 97

def add_child
  raise "Should never call add_child on a limited_layer"
end

#annotate_layerObject



113
114
115
# File 'lib/scout_apm/limited_layer.rb', line 113

def annotate_layer(*)
  raise "Should never call annotate_layer on a limited_layer"
end

#annotationsObject



64
65
66
# File 'lib/scout_apm/limited_layer.rb', line 64

def annotations
  nil
end

#backtraceObject



87
88
89
# File 'lib/scout_apm/limited_layer.rb', line 87

def backtrace
  nil
end

#caller_arrayObject



125
126
127
# File 'lib/scout_apm/limited_layer.rb', line 125

def caller_array
  raise "Should never call caller_array on a limited_layer"
end

#capture_backtrace!Object



121
122
123
# File 'lib/scout_apm/limited_layer.rb', line 121

def capture_backtrace!
  raise "Should never call capture_backtrace on a limited_layer"
end

#childrenObject



60
61
62
# File 'lib/scout_apm/limited_layer.rb', line 60

def children
  Set.new
end

#countObject



49
50
51
# File 'lib/scout_apm/limited_layer.rb', line 49

def count
  @total_layers
end

#descObject



83
84
85
# File 'lib/scout_apm/limited_layer.rb', line 83

def desc
  nil
end

#desc=Object



109
110
111
# File 'lib/scout_apm/limited_layer.rb', line 109

def desc=(*)
  raise "Should never call desc on a limited_layer"
end

#legacy_metric_nameObject

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.



56
57
58
# File 'lib/scout_apm/limited_layer.rb', line 56

def legacy_metric_name
  "#{type}/Limited"
end

#limited?Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/scout_apm/limited_layer.rb', line 72

def limited?
  true
end

#record_allocations!Object



105
106
107
# File 'lib/scout_apm/limited_layer.rb', line 105

def record_allocations!
  raise "Should never call record_allocations! on a limited_layer"
end

#record_stop_time!Object



101
102
103
# File 'lib/scout_apm/limited_layer.rb', line 101

def record_stop_time!(*)
  raise "Should never call record_stop_time! on a limited_layer"
end

#subscopable!Object



117
118
119
# File 'lib/scout_apm/limited_layer.rb', line 117

def subscopable!
  raise "Should never call subscopable! on a limited_layer"
end

#subscopable?Boolean

Stub out some methods with static default values #

Returns:

  • (Boolean)


79
80
81
# File 'lib/scout_apm/limited_layer.rb', line 79

def subscopable?
  false
end

#to_sObject



68
69
70
# File 'lib/scout_apm/limited_layer.rb', line 68

def to_s
  "<LimitedLayer type=#{type} count=#{count}>"
end

#total_allocationsObject



41
42
43
# File 'lib/scout_apm/limited_layer.rb', line 41

def total_allocations
  @total_allocations
end

#total_call_timeObject



33
34
35
# File 'lib/scout_apm/limited_layer.rb', line 33

def total_call_time
  @total_call_time
end

#total_exclusive_allocationsObject



45
46
47
# File 'lib/scout_apm/limited_layer.rb', line 45

def total_exclusive_allocations
  @total_exclusive_allocations
end

#total_exclusive_timeObject



37
38
39
# File 'lib/scout_apm/limited_layer.rb', line 37

def total_exclusive_time
  @total_exclusive_time
end