Skip to content

Commit

Permalink
Merge pull request #266 from jeremycw/backtrace
Browse files Browse the repository at this point in the history
Add backtrace_path_filter config option
  • Loading branch information
hmadison authored Apr 12, 2022
2 parents 8a9c0e9 + b0443e8 commit c9309eb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/instana/tracing/span.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ def initialize(name, parent_ctx: nil, start_time: ::Instana::Util.now_in_ms)
# @param limit [Integer] Limit the backtrace to the top <limit> frames
#
def add_stack(limit: 30, stack: Kernel.caller)
cleaner = ::Instana.config[:backtrace_cleaner]
stack = cleaner.call(stack) if cleaner

@data[:stack] = stack
.map do |call|
file, line, *method = call.split(':')
Expand Down
12 changes: 12 additions & 0 deletions test/tracing/span_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ def test_span_collect_backtraces
Instana.config[:collect_backtraces] = false
end

def test_span_backtrace_cleaner
Instana.config[:collect_backtraces] = true
Instana.config[:backtrace_cleaner] =
->(trace) { trace.filter { |line| line.include?("lib/instana") } }
span = Instana::Span.new(:excon)

assert_equal 1, span[:stack].size
ensure
Instana.config[:backtrace_cleaner] = nil
Instana.config[:collect_backtraces] = false
end

def test_span_stack_over_limit
def inner(depth = 50, &blk) # rubocop:disable Lint/NestedMethodDefinition
return blk.call if depth.zero?
Expand Down

0 comments on commit c9309eb

Please sign in to comment.