Class: ScoutApm::SlowTransaction

Inherits:
Object
  • Object
show all
Defined in:
lib/scout_apm/slow_transaction.rb

Constant Summary collapse

BACKTRACE_THRESHOLD =

the minimum threshold 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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, metric_name, total_call_time, metrics, context, time, raw_stackprof) ⇒ SlowTransaction

Returns a new instance of SlowTransaction.



32
33
34
35
36
37
38
39
40
41
# File 'lib/scout_apm/slow_transaction.rb', line 32

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

#contextObject (readonly)

Returns the value of attribute context.



12
13
14
# File 'lib/scout_apm/slow_transaction.rb', line 12

def context
  @context
end

#metaObject (readonly)

Returns the value of attribute meta.



10
11
12
# File 'lib/scout_apm/slow_transaction.rb', line 10

def meta
  @meta
end

#metric_nameObject (readonly)

Returns the value of attribute metric_name.



7
8
9
# File 'lib/scout_apm/slow_transaction.rb', line 7

def metric_name
  @metric_name
end

#metricsObject (readonly)

Returns the value of attribute metrics.



9
10
11
# File 'lib/scout_apm/slow_transaction.rb', line 9

def metrics
  @metrics
end

#profObject (readonly)

Returns the value of attribute prof.



14
15
16
# File 'lib/scout_apm/slow_transaction.rb', line 14

def prof
  @prof
end

#raw_profObject (readonly)

Returns the value of attribute raw_prof.



15
16
17
# File 'lib/scout_apm/slow_transaction.rb', line 15

def raw_prof
  @raw_prof
end

#timeObject (readonly)

Returns the value of attribute time.



13
14
15
# File 'lib/scout_apm/slow_transaction.rb', line 13

def time
  @time
end

#total_call_timeObject (readonly)

Returns the value of attribute total_call_time.



8
9
10
# File 'lib/scout_apm/slow_transaction.rb', line 8

def total_call_time
  @total_call_time
end

#uriObject (readonly)

Returns the value of attribute uri.



11
12
13
# File 'lib/scout_apm/slow_transaction.rb', line 11

def uri
  @uri
end

Class Method Details

.backtrace_parser(backtrace) ⇒ Object

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



21
22
23
24
25
26
27
28
29
30
# File 'lib/scout_apm/slow_transaction.rb', line 21

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

#clear_metrics!Object

Used to remove metrics when the payload will be too large.



44
45
46
47
# File 'lib/scout_apm/slow_transaction.rb', line 44

def clear_metrics!
  @metrics = nil
  self
end