Class: ScoutApm::MetricMeta
- Inherits:
-
Object
- Object
- ScoutApm::MetricMeta
- Includes:
- BucketNameSplitter
- Defined in:
- lib/scout_apm/metric_meta.rb
Instance Attribute Summary collapse
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#desc ⇒ Object
Returns the value of attribute desc.
-
#extra ⇒ Object
Returns the value of attribute extra.
-
#metric_id ⇒ Object
Returns the value of attribute metric_id.
-
#metric_name ⇒ Object
Returns the value of attribute metric_name.
-
#scope ⇒ Object
Returns the value of attribute scope.
Class Method Summary collapse
Instance Method Summary collapse
- #==(o) ⇒ Object
- #as_json ⇒ Object
- #backtrace ⇒ Object
-
#backtrace=(bt) ⇒ Object
This should be abstracted to a true accessor …
- #eql?(o) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(metric_name, options = {}) ⇒ MetricMeta
constructor
A new instance of MetricMeta.
-
#key_metric? ⇒ Boolean
A key metric is the “core” of a request - either the Rails controller reached, or the background Job executed.
- #name ⇒ Object
-
#to_json(*a) ⇒ Object
To avoid conflicts with different JSON libaries.
-
#type ⇒ Object
Unsure if type or bucket is a better name.
Methods included from BucketNameSplitter
#bucket_name, #bucket_type, #key
Constructor Details
#initialize(metric_name, options = {}) ⇒ MetricMeta
Returns a new instance of MetricMeta.
6 7 8 9 10 11 12 |
# File 'lib/scout_apm/metric_meta.rb', line 6 def initialize(metric_name, = {}) @metric_name = metric_name @metric_id = nil @scope = [:scope] @desc = [:desc] @extra = {} end |
Instance Attribute Details
#client_id ⇒ Object
Returns the value of attribute client_id.
15 16 17 |
# File 'lib/scout_apm/metric_meta.rb', line 15 def client_id @client_id end |
#desc ⇒ Object
Returns the value of attribute desc.
16 17 18 |
# File 'lib/scout_apm/metric_meta.rb', line 16 def desc @desc end |
#extra ⇒ Object
Returns the value of attribute extra.
16 17 18 |
# File 'lib/scout_apm/metric_meta.rb', line 16 def extra @extra end |
#metric_id ⇒ Object
Returns the value of attribute metric_id.
13 14 15 |
# File 'lib/scout_apm/metric_meta.rb', line 13 def metric_id @metric_id end |
#metric_name ⇒ Object
Returns the value of attribute metric_name.
13 14 15 |
# File 'lib/scout_apm/metric_meta.rb', line 13 def metric_name @metric_name end |
#scope ⇒ Object
Returns the value of attribute scope.
14 15 16 |
# File 'lib/scout_apm/metric_meta.rb', line 14 def scope @scope end |
Class Method Details
.key_metric?(metric_name) ⇒ Boolean
32 33 34 |
# File 'lib/scout_apm/metric_meta.rb', line 32 def self.key_metric?(metric_name) !!(metric_name =~ /\A(Controller|Job)\//) end |
Instance Method Details
#==(o) ⇒ Object
41 42 43 |
# File 'lib/scout_apm/metric_meta.rb', line 41 def ==(o) self.eql?(o) end |
#as_json ⇒ Object
69 70 71 72 73 |
# File 'lib/scout_apm/metric_meta.rb', line 69 def as_json json_attributes = [:bucket, :name, :desc, :extra, [:scope, :scope_hash]] # query, stack_trace ScoutApm::AttributeArranger.call(self, json_attributes) end |
#backtrace ⇒ Object
50 51 52 |
# File 'lib/scout_apm/metric_meta.rb', line 50 def backtrace extra[:backtrace] end |
#backtrace=(bt) ⇒ Object
This should be abstracted to a true accessor … earned it.
46 47 48 |
# File 'lib/scout_apm/metric_meta.rb', line 46 def backtrace=(bt) extra[:backtrace] = bt end |
#eql?(o) ⇒ Boolean
61 62 63 64 65 66 67 |
# File 'lib/scout_apm/metric_meta.rb', line 61 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 ⇒ Object
54 55 56 57 58 59 |
# File 'lib/scout_apm/metric_meta.rb', line 54 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? ⇒ Boolean
A key metric is the “core” of a request - either the Rails controller reached, or the background Job executed
28 29 30 |
# File 'lib/scout_apm/metric_meta.rb', line 28 def key_metric? self.class.key_metric?(metric_name) end |
#name ⇒ Object
23 24 25 |
# File 'lib/scout_apm/metric_meta.rb', line 23 def name bucket_name end |
#to_json(*a) ⇒ Object
To avoid conflicts with different JSON libaries
37 38 39 |
# File 'lib/scout_apm/metric_meta.rb', line 37 def to_json(*a) %Q[{"metric_id":#{metric_id || 'null'},"metric_name":#{metric_name.to_json},"scope":#{scope.to_json || 'null'}}] end |
#type ⇒ Object
Unsure if type or bucket is a better name.
19 20 21 |
# File 'lib/scout_apm/metric_meta.rb', line 19 def type bucket_type end |