class NewRelic::Agent::TransactionMetrics
Constants
- DEFAULT_PROC
Public Class Methods
new()
click to toggle source
# File lib/new_relic/agent/transaction_metrics.rb, line 14 def initialize @unscoped = Hash.new(&DEFAULT_PROC) @scoped = Hash.new(&DEFAULT_PROC) end
Public Instance Methods
[](key)
click to toggle source
# File lib/new_relic/agent/transaction_metrics.rb, line 39 def [](key) @unscoped[key] end
_record_metrics(names, value, aux, target, &blk)
click to toggle source
# File lib/new_relic/agent/transaction_metrics.rb, line 51 def _record_metrics(names, value, aux, target, &blk) # This looks dumb, but we're avoiding an extra Array allocation. case names when Array names.each do |name| target[name].record(value, aux, &blk) end else target[names].record(value, aux, &blk) end end
each_scoped() { |name, stats| ... }
click to toggle source
# File lib/new_relic/agent/transaction_metrics.rb, line 47 def each_scoped @scoped.each { |name, stats| yield name, stats } end
each_unscoped() { |name, stats| ... }
click to toggle source
# File lib/new_relic/agent/transaction_metrics.rb, line 43 def each_unscoped @unscoped.each { |name, stats| yield name, stats } end
has_key?(key)
click to toggle source
# File lib/new_relic/agent/transaction_metrics.rb, line 35 def has_key?(key) @unscoped.has_key?(key) end
record_scoped_and_unscoped(names, value=nil, aux=nil, &blk)
click to toggle source
As a general rule, when recording a scoped metric, the corresponding unscoped metric should always be recorded as well.
As an optimization, scoped metrics are representated within this class only by their entries in the @scoped Hash, and it's up to clients to propagate them into unscoped metrics as well when instances of this class are merged into the global metric store.
# File lib/new_relic/agent/transaction_metrics.rb, line 27 def record_scoped_and_unscoped(names, value=nil, aux=nil, &blk) _record_metrics(names, value, aux, @scoped, &blk) end
record_unscoped(names, value=nil, aux=nil, &blk)
click to toggle source
# File lib/new_relic/agent/transaction_metrics.rb, line 31 def record_unscoped(names, value=nil, aux=nil, &blk) _record_metrics(names, value, aux, @unscoped, &blk) end