Module: TemplateStreaming::NewRelic::StatsEngine
- Defined in:
- lib/template_streaming/new_relic.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#finish_accumulating ⇒ Object
Freeze and clear the list of accumulated stats, and add the aggregated stats to the unaccumulated stats.
- #get_custom_stats_with_template_streaming(metric_name, stat_class) ⇒ Object
- #get_stats_no_scope_with_template_streaming(metric_name) ⇒ Object
- #get_stats_with_template_streaming(metric_name, use_scope = true, scoped_metric_only = false) ⇒ Object
-
#start_accumulating(*metric_names) ⇒ Object
Start accumulating the given
metric_names
.
Class Method Details
.included(base) ⇒ Object
180 181 182 183 184 185 186 |
# File 'lib/template_streaming/new_relic.rb', line 180 def self.included(base) base.class_eval do alias_method_chain :get_stats_no_scope, :template_streaming alias_method_chain :get_custom_stats, :template_streaming alias_method_chain :get_stats, :template_streaming end end |
Instance Method Details
#finish_accumulating ⇒ Object
Freeze and clear the list of accumulated stats, and add the aggregated stats to the unaccumulated stats.
207 208 209 210 211 212 213 |
# File 'lib/template_streaming/new_relic.rb', line 207 def finish_accumulating accumulated_stats_hash.each do |metric_name, stats| stats.finish_accumulating stats.freeze end accumulated_stats_hash.clear end |
#get_custom_stats_with_template_streaming(metric_name, stat_class) ⇒ Object
220 221 222 223 |
# File 'lib/template_streaming/new_relic.rb', line 220 def get_custom_stats_with_template_streaming(metric_name, stat_class) accumulated_stats_hash[metric_name] || get_custom_stats_without_template_streaming(metric_name, stat_class) end |
#get_stats_no_scope_with_template_streaming(metric_name) ⇒ Object
215 216 217 218 |
# File 'lib/template_streaming/new_relic.rb', line 215 def get_stats_no_scope_with_template_streaming(metric_name) accumulated_stats_hash[metric_name] || get_stats_no_scope_without_template_streaming(metric_name) end |
#get_stats_with_template_streaming(metric_name, use_scope = true, scoped_metric_only = false) ⇒ Object
225 226 227 228 229 230 |
# File 'lib/template_streaming/new_relic.rb', line 225 def get_stats_with_template_streaming(metric_name, use_scope = true, scoped_metric_only = false) key = scoped_metric_only || (use_scope && scope_name && scope_name != metric_name) ? ::NewRelic::MetricSpec.new(metric_name, scope_name) : metric_name accumulated_stats_hash[key] || get_stats_without_template_streaming(metric_name, use_scope, scoped_metric_only) end |
#start_accumulating(*metric_names) ⇒ Object
Start accumulating the given metric_names
.
The metric_names can be either strings or MetricSpec’s. See StatsEngine::MetricStats for which metric names you need to accumulate.
195 196 197 198 199 200 201 |
# File 'lib/template_streaming/new_relic.rb', line 195 def start_accumulating(*metric_names) metric_names.each do |metric_name| unaccumulated_stats = stats_hash[metric_name] ||= ::NewRelic::MethodTraceStats.new accumulated_stats = AccumulatedMethodTraceStats.new(unaccumulated_stats) accumulated_stats_hash[metric_name] ||= accumulated_stats end end |