Module: Mmtrix::Agent::StatsEngine::MetricStats

Defined in:
lib/mmtrix/agent/stats_engine/metric_stats.rb

Overview

Handles methods related to actual Metric collection

Instance Method Summary collapse

Instance Method Details

#get_stats(metric_name, _ = true, scoped_metric_only = false, scope = nil) ⇒ Object

Deprecated.

This method is deprecated and not thread safe, and should not be used by any new client code. Use Mmtrix::Agent.record_metric instead.

If scoped_metric_only is true, only a scoped metric is created (used by rendering metrics which by definition are per controller only) Leaving second, unused parameter for compatibility



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/mmtrix/agent/stats_engine/metric_stats.rb', line 135

def get_stats(metric_name, _ = true, scoped_metric_only = false, scope = nil)
  stats = nil
  with_stats_lock do
    if scoped_metric_only
      stats = @stats_hash[Mmtrix::MetricSpec.new(metric_name, scope)]
    else
      unscoped_spec = Mmtrix::MetricSpec.new(metric_name)
      unscoped_stats = @stats_hash[unscoped_spec]
      if scope && scope != metric_name
        scoped_spec = Mmtrix::MetricSpec.new(metric_name, scope)
        scoped_stats = @stats_hash[scoped_spec]
        stats = Mmtrix::Agent::ChainedStats.new(scoped_stats, unscoped_stats)
      else
        stats = unscoped_stats
      end
    end
  end
  stats
end

#get_stats_no_scope(metric_name) ⇒ Object

Deprecated.

This method is deprecated and not thread safe, and should not be used by any new client code.

Lookup the Stats object for a given unscoped metric, returning a new Stats object if one did not exist previously.



121
122
123
# File 'lib/mmtrix/agent/stats_engine/metric_stats.rb', line 121

def get_stats_no_scope(metric_name)
  get_stats(metric_name, false)
end