Class: ScoutApm::LayerMetricConverter
- Inherits:
-
LayerConverterBase
- Object
- LayerConverterBase
- ScoutApm::LayerMetricConverter
- Defined in:
- lib/scout_apm/layer_converter.rb
Overview
Take a TrackedRequest and turn it into a hash of:
MetricMeta => MetricStats
This will do some merging of metrics as duplicate calls are seen.
Instance Attribute Summary
Attributes inherited from LayerConverterBase
#request, #root_layer, #walker
Instance Method Summary collapse
- #call ⇒ Object
-
#create_metrics ⇒ Object
Full metrics from this request.
Methods inherited from LayerConverterBase
Constructor Details
This class inherits a constructor from ScoutApm::LayerConverterBase
Instance Method Details
#call ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/scout_apm/layer_converter.rb', line 33 def call scope = scope_layer # TODO: Track requests that never reach a Controller (for example, when # Middleware decides to return rather than passing onward) return {} unless scope create_metrics end |
#create_metrics ⇒ Object
Full metrics from this request. These get aggregated in Store for the overview metrics, or 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.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/scout_apm/layer_converter.rb', line 47 def create_metrics metric_hash = Hash.new walker.walk do |layer| = if layer == scope_layer # We don't scope the controller under itself {} else {:scope => scope_layer.legacy_metric_name} end # we don't need to use the full metric name for scoped metrics as we only display metrics aggregrated # by type. metric_name = .has_key?(:scope) ? layer.type : layer.legacy_metric_name = MetricMeta.new(metric_name, ) metric_hash[] ||= MetricStats.new( .has_key?(:scope) ) stat = metric_hash[] stat.update!(layer.total_call_time, layer.total_exclusive_time) end metric_hash end |