class ScoutApm::MetricMeta

Attributes

client_id[RW]
desc[RW]
extra[RW]
metric_id[RW]
metric_name[RW]
scope[RW]

Public Class Methods

key_metric?(metric_name) click to toggle source
# File lib/scout_apm/metric_meta.rb, line 32
def self.key_metric?(metric_name)
  !!(metric_name =~ /\A(Controller|Job)\//)
end
new(metric_name, options = {}) click to toggle source
# File lib/scout_apm/metric_meta.rb, line 6
def initialize(metric_name, options = {})
  @metric_name = metric_name
  @metric_id = nil
  @scope = options[:scope]
  @desc = options[:desc]
  @extra = {}
end

Public Instance Methods

==(o) click to toggle source
# File lib/scout_apm/metric_meta.rb, line 36
def ==(o)
  self.eql?(o)
end
as_json() click to toggle source
# File lib/scout_apm/metric_meta.rb, line 64
def as_json
  json_attributes = [:bucket, :name, :desc, :extra, [:scope, :scope_hash]]
  # query, stack_trace
  ScoutApm::AttributeArranger.call(self, json_attributes)
end
backtrace() click to toggle source
# File lib/scout_apm/metric_meta.rb, line 45
def backtrace
  extra[:backtrace]
end
backtrace=(bt) click to toggle source

This should be abstracted to a true accessor … earned it.

# File lib/scout_apm/metric_meta.rb, line 41
def backtrace=(bt)
  extra[:backtrace] = bt
end
eql?(o) click to toggle source
# File lib/scout_apm/metric_meta.rb, line 56
def eql?(o)
 self.class             == o.class                &&
   metric_name.downcase == o.metric_name.downcase &&
   scope                == o.scope                &&
   client_id            == o.client_id            &&
   desc                 == o.desc
end
hash() click to toggle source
# File lib/scout_apm/metric_meta.rb, line 49
def hash
  h = metric_name.downcase.hash
  h ^= scope.downcase.hash unless scope.nil?
  h ^= desc.downcase.hash unless desc.nil?
  h
end
key_metric?() click to toggle source

A key metric is the “core” of a request - either the Rails controller reached, or the background Job executed

# File lib/scout_apm/metric_meta.rb, line 28
def key_metric?
  self.class.key_metric?(metric_name)
end
name() click to toggle source
# File lib/scout_apm/metric_meta.rb, line 23
def name
  bucket_name
end
type() click to toggle source

Unsure if type or bucket is a better name.

# File lib/scout_apm/metric_meta.rb, line 19
def type
  bucket_type
end