lib/elastic_apm/stacktrace.rb in elastic-apm-0.2.0 vs lib/elastic_apm/stacktrace.rb in elastic-apm-0.3.0

- old
+ new

@@ -1,29 +1,32 @@ # frozen_string_literal: true require 'elastic_apm/stacktrace/frame' +require 'elastic_apm/stacktrace/line_cache' module ElasticAPM # @api private class Stacktrace + GEMS_REGEX = %r{/gems/} + def initialize(backtrace) @backtrace = backtrace end attr_reader :frames - def self.build(builder, backtrace) + def self.build(config, backtrace) return nil unless backtrace stack = new(backtrace) - stack.build_frames(builder) + stack.build_frames(config) stack end - def build_frames(builder) - @frames = @backtrace.reverse.map do |line| - build_frame(builder, line) + def build_frames(config) + @frames = @backtrace.map do |line| + build_frame(config, line) end end def length frames.length @@ -51,18 +54,20 @@ end [file, number, method, module_name] end - def build_frame(_builder, line) + def build_frame(config, line) abs_path, lineno, function, _module_name = parse_line(line) frame = Frame.new frame.abs_path = abs_path frame.filename = strip_load_path(abs_path) frame.function = function frame.lineno = lineno.to_i frame.build_context 3 + frame.library_frame = + !(abs_path && abs_path.start_with?(config.root_path)) frame end def strip_load_path(path)