Class: ScoutApm::LayerConverters::DatabaseConverter
- Inherits:
-
ConverterBase
- Object
- ConverterBase
- ScoutApm::LayerConverters::DatabaseConverter
- Defined in:
- lib/scout_apm/layer_converters/database_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
-
#initialize ⇒ DatabaseConverter
constructor
A new instance of DatabaseConverter.
- #record! ⇒ Object
- #register_hooks(walker) ⇒ Object
- #skip_layer?(layer) ⇒ Boolean
Methods inherited from ConverterBase
#attach_backtraces, #limited?, #make_meta_options, #make_meta_options_desc_hash, #make_meta_options_scope, #over_metric_limit?, #scope_layer, #store_aggregate_metric, #store_backtrace, #store_specific_metric, #subscope_name, #subscoped?
Constructor Details
#initialize ⇒ DatabaseConverter
Returns a new instance of DatabaseConverter.
4 5 6 7 |
# File 'lib/scout_apm/layer_converters/database_converter.rb', line 4 def initialize(*) super @db_query_metric_set = DbQueryMetricSet.new(context) end |
Instance Method Details
#record! ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/scout_apm/layer_converters/database_converter.rb', line 28 def record! # Everything in the metric set here is from a single transaction, which # we want to keep track of. (One web call did a User#find 10 times, but # only due to 1 http request) @db_query_metric_set.increment_transaction_count! @store.track_db_query_metrics!(@db_query_metric_set) nil # not returning anything in the layer results ... not used end |
#register_hooks(walker) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/scout_apm/layer_converters/database_converter.rb', line 9 def register_hooks(walker) super return unless scope_layer walker.on do |layer| next if skip_layer?(layer) stat = DbQueryMetricStats.new( model_name(layer), operation_name(layer), scope_layer.legacy_metric_name, # controller_scope 1, # count, this is a single query, so 1 layer.total_call_time, records_returned(layer) ) @db_query_metric_set << stat end end |
#skip_layer?(layer) ⇒ Boolean
38 39 40 41 42 |
# File 'lib/scout_apm/layer_converters/database_converter.rb', line 38 def skip_layer?(layer) layer.type != 'ActiveRecord' || layer.limited? || super end |