Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sentry-ruby/lib/sentry/interfaces/stacktrace_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class StacktraceBuilder
# @return [Boolean]
attr_reader :strip_backtrace_load_path

# @return [FilenameCache]
attr_reader :filename_cache

# @param project_root [String]
# @param app_dirs_pattern [Regexp, nil]
# @param linecache [LineCache]
Expand Down
1 change: 1 addition & 0 deletions sentry-ruby/lib/sentry/profiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def initialize(configuration)
@project_root = configuration.project_root
@app_dirs_pattern = configuration.app_dirs_pattern
@in_app_pattern = Regexp.new("^(#{@project_root}/)?#{@app_dirs_pattern}")
@filename_cache = configuration.stacktrace_builder.filename_cache
end

def start
Expand Down
22 changes: 1 addition & 21 deletions sentry-ruby/lib/sentry/profiler/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,8 @@ def in_app?(abs_path)
abs_path.match?(@in_app_pattern)
end

# copied from stacktrace.rb since I don't want to touch existing code
# TODO-neel-profiler try to fetch this from stackprof once we patch
# the native extension
def compute_filename(abs_path, in_app)
return nil if abs_path.nil?

under_project_root = @project_root && abs_path.start_with?(@project_root)

prefix =
if under_project_root && in_app
@project_root
else
longest_load_path = $LOAD_PATH.select { |path| abs_path.start_with?(path.to_s) }.max_by(&:size)

if under_project_root
longest_load_path || @project_root
else
longest_load_path
end
end

prefix ? abs_path[prefix.to_s.chomp(File::SEPARATOR).length + 1..-1] : abs_path
@filename_cache.compute_filename(abs_path, in_app, true)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why default strip_backtrace_load_path to true here?

end

def split_module(name)
Expand Down
3 changes: 2 additions & 1 deletion sentry-ruby/lib/sentry/vernier/output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ class Output

attr_reader :profile

def initialize(profile, project_root:, in_app_pattern:, app_dirs_pattern:)
def initialize(profile, project_root:, in_app_pattern:, app_dirs_pattern:, filename_cache:)
@profile = profile
@project_root = project_root
@in_app_pattern = in_app_pattern
@app_dirs_pattern = app_dirs_pattern
@filename_cache = filename_cache
end

def to_h
Expand Down
4 changes: 3 additions & 1 deletion sentry-ruby/lib/sentry/vernier/profiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def initialize(configuration)
@project_root = configuration.project_root
@app_dirs_pattern = configuration.app_dirs_pattern
@in_app_pattern = Regexp.new("^(#{@project_root}/)?#{@app_dirs_pattern}")
@filename_cache = configuration.stacktrace_builder.filename_cache
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it worth to test that filename_cache is shared between profiler & stacktrace_builder?

end

def set_initial_sample_decision(transaction_sampled)
Expand Down Expand Up @@ -125,7 +126,8 @@ def output
result,
project_root: @project_root,
app_dirs_pattern: @app_dirs_pattern,
in_app_pattern: @in_app_pattern
in_app_pattern: @in_app_pattern,
filename_cache: @filename_cache
)
end
end
Expand Down
Loading