Class: ScoutApm::SlowTransaction
- Inherits:
-
Object
- Object
- ScoutApm::SlowTransaction
- Includes:
- BucketNameSplitter
- Defined in:
- lib/scout_apm/slow_transaction.rb
Constant Summary collapse
- BACKTRACE_THRESHOLD =
the minimum threshold in seconds to record the backtrace for a metric.
0.5
- BACKTRACE_LIMIT =
Max length of callers to display
5
- MAX_SIZE =
Limits the size of the metric hash to prevent a metric explosion.
100
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
-
#metric_name ⇒ Object
readonly
Returns the value of attribute metric_name.
-
#metrics ⇒ Object
readonly
Returns the value of attribute metrics.
-
#prof ⇒ Object
readonly
Returns the value of attribute prof.
-
#raw_prof ⇒ Object
readonly
Returns the value of attribute raw_prof.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#total_call_time ⇒ Object
readonly
Returns the value of attribute total_call_time.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Class Method Summary collapse
-
.backtrace_parser(backtrace) ⇒ Object
TODO: Move this out of SlowTransaction, it doesn’t have much to do w/ slow trans other than being a piece of data that ends up in it.
Instance Method Summary collapse
- #as_json ⇒ Object
-
#clear_metrics! ⇒ Object
Used to remove metrics when the payload will be too large.
- #context_hash ⇒ Object
- #has_metrics? ⇒ Boolean
-
#initialize(uri, metric_name, total_call_time, metrics, context, time, raw_stackprof) ⇒ SlowTransaction
constructor
A new instance of SlowTransaction.
Methods included from BucketNameSplitter
Constructor Details
#initialize(uri, metric_name, total_call_time, metrics, context, time, raw_stackprof) ⇒ SlowTransaction
Returns a new instance of SlowTransaction.
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/scout_apm/slow_transaction.rb', line 37 def initialize(uri, metric_name, total_call_time, metrics, context, time, raw_stackprof) @uri = uri @metric_name = metric_name @total_call_time = total_call_time @metrics = metrics @context = context @time = time @prof = ScoutApm::StackprofTreeCollapser.new(raw_stackprof).call @raw_prof = raw_stackprof # Send whole data up to server end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
14 15 16 |
# File 'lib/scout_apm/slow_transaction.rb', line 14 def context @context end |
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
12 13 14 |
# File 'lib/scout_apm/slow_transaction.rb', line 12 def @meta end |
#metric_name ⇒ Object (readonly)
Returns the value of attribute metric_name.
9 10 11 |
# File 'lib/scout_apm/slow_transaction.rb', line 9 def metric_name @metric_name end |
#metrics ⇒ Object (readonly)
Returns the value of attribute metrics.
11 12 13 |
# File 'lib/scout_apm/slow_transaction.rb', line 11 def metrics @metrics end |
#prof ⇒ Object (readonly)
Returns the value of attribute prof.
16 17 18 |
# File 'lib/scout_apm/slow_transaction.rb', line 16 def prof @prof end |
#raw_prof ⇒ Object (readonly)
Returns the value of attribute raw_prof.
17 18 19 |
# File 'lib/scout_apm/slow_transaction.rb', line 17 def raw_prof @raw_prof end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
15 16 17 |
# File 'lib/scout_apm/slow_transaction.rb', line 15 def time @time end |
#total_call_time ⇒ Object (readonly)
Returns the value of attribute total_call_time.
10 11 12 |
# File 'lib/scout_apm/slow_transaction.rb', line 10 def total_call_time @total_call_time end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
13 14 15 |
# File 'lib/scout_apm/slow_transaction.rb', line 13 def uri @uri end |
Class Method Details
.backtrace_parser(backtrace) ⇒ Object
TODO: Move this out of SlowTransaction, it doesn’t have much to do w/ slow trans other than being a piece of data that ends up in it.
Given a call stack, generates a filtered backtrace that:
-
Limits to the app/models, app/controllers, or app/views directories
-
Limits to 5 total callers
-
Makes the app folder the top-level folder used in trace info
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/scout_apm/slow_transaction.rb', line 26 def self.backtrace_parser(backtrace) stack = [] backtrace.each do |c| if m=c.match(/(\/app\/(controllers|models|views)\/.+)/) stack << m[1] break if stack.size == BACKTRACE_LIMIT end end stack end |
Instance Method Details
#as_json ⇒ Object
58 59 60 61 |
# File 'lib/scout_apm/slow_transaction.rb', line 58 def as_json json_attributes = [:key, :time, :total_call_time, :uri, [:context, :context_hash], :prof] ScoutApm::AttributeArranger.call(self, json_attributes) end |
#clear_metrics! ⇒ Object
Used to remove metrics when the payload will be too large.
49 50 51 52 |
# File 'lib/scout_apm/slow_transaction.rb', line 49 def clear_metrics! @metrics = nil self end |
#context_hash ⇒ Object
63 64 65 |
# File 'lib/scout_apm/slow_transaction.rb', line 63 def context_hash context.to_hash end |
#has_metrics? ⇒ Boolean
54 55 56 |
# File 'lib/scout_apm/slow_transaction.rb', line 54 def has_metrics? metrics and metrics.any? end |