Class: ScoutApm::LayerConverters::SlowRequestConverter
- Inherits:
-
ConverterBase
- Object
- ConverterBase
- ScoutApm::LayerConverters::SlowRequestConverter
- Defined in:
- lib/scout_apm/layer_converters/slow_request_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
Unconditionally attempts to convert this into a SlowTransaction object.
-
#create_metrics ⇒ Object
Full metrics from this request.
-
#name ⇒ Object
ScoreItemSet API #.
-
#record! ⇒ Object
Converter API #.
- #score ⇒ Object
-
#span_trace ⇒ Object
Also create a new style trace.
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, #skip_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
Unconditionally attempts to convert this into a SlowTransaction object. Can return nil if the request didn’t have any scope_layer.
26 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 |
# File 'lib/scout_apm/layer_converters/slow_request_converter.rb', line 26 def call return nil unless request.web? return nil unless scope_layer context.slow_request_policy.stored!(request) # record the change in memory usage mem_delta = ScoutApm::Instruments::Process::ProcessMemory.new(context).rss_to_mb(@request.capture_mem_delta!) uri = request.annotations[:uri] || "" timing_metrics, allocation_metrics = create_metrics unless ScoutApm::Instruments::Allocations::ENABLED allocation_metrics = {} end SlowTransaction.new(context, uri, scope_layer.legacy_metric_name, root_layer.total_call_time, timing_metrics, allocation_metrics, request.context, root_layer.stop_time, [], # stackprof, now unused. mem_delta, root_layer.total_allocations, @points, limited?, span_trace) end |
#create_metrics ⇒ Object
Full metrics from this request. These get stored permanently in a SlowTransaction. Some merging of metrics will happen here, so if a request calls the same ActiveRecord or View repeatedly, it’ll get merged.
This returns a 2-element of Metric Hashes (the first element is timing metrics, the second element is allocation metrics)
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/scout_apm/layer_converters/slow_request_converter.rb', line 64 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) 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 |
#name ⇒ Object
ScoreItemSet API #
21 |
# File 'lib/scout_apm/layer_converters/slow_request_converter.rb', line 21 def name; request.unique_name; end |
#record! ⇒ Object
Converter API #
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/scout_apm/layer_converters/slow_request_converter.rb', line 7 def record! return nil unless request.web? @points = context.slow_request_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_transaction!(self) nil # not returning anything in the layer results ... not used end |
#score ⇒ Object
22 |
# File 'lib/scout_apm/layer_converters/slow_request_converter.rb', line 22 def score; @points; end |
#span_trace ⇒ Object
Also create a new style trace. This is not a good #
spot for this long term, but fixes an issue for now. #
92 93 94 95 96 |
# File 'lib/scout_apm/layer_converters/slow_request_converter.rb', line 92 def span_trace ScoutApm::LayerConverters::TraceConverter. new(@context, @request, @layer_finder, @store). call end |