Class: ScoutApm::LayerConverters::SlowJobConverter
- Inherits:
-
ConverterBase
- Object
- ConverterBase
- ScoutApm::LayerConverters::SlowJobConverter
- Defined in:
- lib/scout_apm/layer_converters/slow_job_converter.rb
Constant Summary
Constants inherited from ConverterBase
Instance Attribute Summary
Attributes inherited from ConverterBase
#context, #layer_finder, #request, #root_layer
Instance Method Summary collapse
-
#call ⇒ Object
Called by the set to force this to actually be created.
- #create_metrics ⇒ Object
- #job_layer ⇒ Object
-
#name ⇒ Object
ScoreItemSet API #.
- #queue_layer ⇒ Object
-
#record! ⇒ Object
Converter API #.
- #score ⇒ Object
- #skip_layer?(layer) ⇒ Boolean
Methods inherited from ConverterBase
#attach_backtraces, #initialize, #limited?, #make_meta_options, #make_meta_options_desc_hash, #make_meta_options_scope, #over_metric_limit?, #register_hooks, #scope_layer, #store_aggregate_metric, #store_backtrace, #store_specific_metric, #subscope_name, #subscoped?
Constructor Details
This class inherits a constructor from ScoutApm::LayerConverters::ConverterBase
Instance Method Details
#call ⇒ Object
Called by the set to force this to actually be created.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/scout_apm/layer_converters/slow_job_converter.rb', line 27 def call return nil unless request.job? return nil unless layer_finder.queue return nil unless layer_finder.job context.slow_job_policy.stored!(request) # record the change in memory usage mem_delta = ScoutApm::Instruments::Process::ProcessMemory.new(context).rss_to_mb(request.capture_mem_delta!) timing_metrics, allocation_metrics = create_metrics unless ScoutApm::Instruments::Allocations::ENABLED allocation_metrics = {} end SlowJobRecord.new( context, queue_layer.name, job_layer.name, root_layer.stop_time, job_layer.total_call_time, job_layer.total_exclusive_time, request.context, timing_metrics, allocation_metrics, mem_delta, job_layer.total_allocations, score, limited? ) end |
#create_metrics ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/scout_apm/layer_converters/slow_job_converter.rb', line 60 def create_metrics # Create a new walker, and wire up the subscope stuff walker = LayerConverters::DepthFirstWalker.new(self.root_layer) register_hooks(walker) metric_hash = Hash.new allocation_metric_hash = Hash.new walker.on do |layer| next if skip_layer?(layer) # The queue_layer is useful to capture for other reasons, but doesn't # create a MetricMeta/Stat of its own next if layer == queue_layer store_specific_metric(layer, metric_hash, allocation_metric_hash) store_aggregate_metric(layer, metric_hash, allocation_metric_hash) end # And now run through the walk we just defined walker.walk metric_hash = attach_backtraces(metric_hash) allocation_metric_hash = attach_backtraces(allocation_metric_hash) [metric_hash, allocation_metric_hash] end |
#job_layer ⇒ Object
90 |
# File 'lib/scout_apm/layer_converters/slow_job_converter.rb', line 90 def job_layer; layer_finder.job; end |
#name ⇒ Object
ScoreItemSet API #
23 |
# File 'lib/scout_apm/layer_converters/slow_job_converter.rb', line 23 def name; request.unique_name; end |
#queue_layer ⇒ Object
89 |
# File 'lib/scout_apm/layer_converters/slow_job_converter.rb', line 89 def queue_layer; layer_finder.queue; end |
#record! ⇒ Object
Converter API #
11 12 13 14 15 16 17 18 |
# File 'lib/scout_apm/layer_converters/slow_job_converter.rb', line 11 def record! return nil unless request.job? @points = context.slow_job_policy.score(request) # Let the store know we're here, and if it wants our data, it will call # back into #call @store.track_slow_job!(self) end |
#score ⇒ Object
24 |
# File 'lib/scout_apm/layer_converters/slow_job_converter.rb', line 24 def score; @points; end |
#skip_layer?(layer) ⇒ Boolean
88 |
# File 'lib/scout_apm/layer_converters/slow_job_converter.rb', line 88 def skip_layer?(layer); super(layer) || layer == queue_layer; end |