Class: ScoutApm::Utils::BacktraceParser
- Inherits:
-
Object
- Object
- ScoutApm::Utils::BacktraceParser
- Defined in:
- lib/scout_apm/utils/backtrace_parser.rb
Constant Summary collapse
- APP_FRAMES =
will return this many backtrace frames from the app stack.
8
Instance Attribute Summary collapse
-
#call_stack ⇒ Object
readonly
Returns the value of attribute call_stack.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(call_stack, root = ScoutApm::Agent.instance.context.environment.root) ⇒ BacktraceParser
constructor
A new instance of BacktraceParser.
Constructor Details
#initialize(call_stack, root = ScoutApm::Agent.instance.context.environment.root) ⇒ BacktraceParser
Returns a new instance of BacktraceParser.
14 15 16 17 18 19 20 21 |
# File 'lib/scout_apm/utils/backtrace_parser.rb', line 14 def initialize(call_stack, root=ScoutApm::Agent.instance.context.environment.root) @call_stack = call_stack # We can't use a constant as it'd be too early to fetch environment info # # This regex looks for files under the app root, inside lib/, app/, and # config/ dirs, and captures the path under root. @@app_dir_regex = %r[#{root}/((?:lib/|app/|config/).*)] end |
Instance Attribute Details
#call_stack ⇒ Object (readonly)
Returns the value of attribute call_stack.
12 13 14 |
# File 'lib/scout_apm/utils/backtrace_parser.rb', line 12 def call_stack @call_stack end |
Instance Method Details
#call ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/scout_apm/utils/backtrace_parser.rb', line 23 def call stack = [] call_stack.each do |c| if m = c.match(@@app_dir_regex) stack << ScoutApm::Utils::Scm.relative_scm_path(m[1]) break if stack.size == APP_FRAMES end end stack end |