class ScoutApm::DbQueryMetricStats
Constants
- DEFAULT_HISTOGRAM_SIZE
Attributes
Public Class Methods
Source
# File lib/scout_apm/db_query_metric_stats.rb, line 24 def initialize(model_name, operation, scope, call_count, call_time, rows_returned) @model_name = model_name @operation = operation @call_count = call_count @call_time = call_time @min_call_time = call_time @max_call_time = call_time @rows_returned = rows_returned @min_rows_returned = rows_returned @max_rows_returned = rows_returned # Should we have a histogram for timing, and one for rows_returned? # This histogram is for call_time @histogram = NumericHistogram.new(DEFAULT_HISTOGRAM_SIZE) @histogram.add(call_time) @transaction_count = 0 @scope = scope end
Public Instance Methods
Source
# File lib/scout_apm/db_query_metric_stats.rb, line 72 def as_json json_attributes = [ :model_name, :operation, :scope, :transaction_count, :call_count, :histogram, :call_time, :max_call_time, :min_call_time, :max_rows_returned, :min_rows_returned, :rows_returned, ] ScoutApm::AttributeArranger.call(self, json_attributes) end
Source
# File lib/scout_apm/db_query_metric_stats.rb, line 54 def combine!(other) return self if other == self @transaction_count += other.transaction_count @call_count += other.call_count @rows_returned += other.rows_returned @call_time += other.call_time @min_call_time = other.min_call_time if @min_call_time.zero? or other.min_call_time < @min_call_time @max_call_time = other.max_call_time if other.max_call_time > @max_call_time @min_rows_returned = other.min_rows_returned if @min_rows_returned.zero? or other.min_rows_returned < @min_rows_returned @max_rows_returned = other.max_rows_returned if other.max_rows_returned > @max_rows_returned @histogram.combine!(other.histogram) self end
Combine data from another DbQueryMetricStats
into self
. Modifies and returns self
Source
# File lib/scout_apm/db_query_metric_stats.rb, line 98 def increment_transaction_count! @transaction_count += 1 end
Called by the Set on each DbQueryMetricStats
object that it holds, only once during the recording of a transaction.
Don’t call elsewhere, and don’t set to 1 in the initializer.
Source
# File lib/scout_apm/db_query_metric_stats.rb, line 49 def key @key ||= [model_name, operation, scope] end
Merge data in this scope. Used in DbQueryMetricSet