lib/scout_rails/store.rb in scout_rails-1.0.9 vs lib/scout_rails/store.rb in scout_rails-1.1.0

- old
+ new

@@ -69,13 +69,12 @@ # add backtrace for slow calls ... how is exclusive time handled? if duration > ScoutRails::TransactionSample::BACKTRACE_THRESHOLD and !stack_empty meta.extra = {:backtrace => ScoutRails::TransactionSample.backtrace_parser(caller)} end stat = transaction_hash[meta] || ScoutRails::MetricStats.new(!stack_empty) - stat.update!(duration,duration-item.children_time) - transaction_hash[meta] = stat + transaction_hash[meta] = stat if store_metric?(stack_empty) # Uses controllers as the entry point for a transaction. Otherwise, stats are ignored. if stack_empty and meta.metric_name.match(/\AController\//) aggs=aggregate_calls(transaction_hash.dup,meta) store_sample(options[:uri],transaction_hash.dup.merge(aggs),meta,stat) @@ -84,9 +83,17 @@ duplicate.each_pair do |k,v| duplicate[k.dup] = v.dup end merge_data(duplicate.merge({meta.dup => stat.dup})) # aggregrates + controller end + end + + # TODO - Move more logic to TransactionSample + # + # Limits the size of the transaction hash to prevent a large transactions. The final item on the stack + # is allowed to be stored regardless of hash size to wrapup the transaction sample w/the parent metric. + def store_metric?(stack_empty) + transaction_hash.size < ScoutRails::TransactionSample::MAX_SIZE or stack_empty end # Returns the top-level category names used in the +metrics+ hash. def categories(metrics) cats = Set.new \ No newline at end of file