lib/instana/tracing/span.rb in instana-1.13.0 vs lib/instana/tracing/span.rb in instana-1.192.0

- old
+ new

@@ -1,12 +1,12 @@ module Instana class Span REGISTERED_SPANS = [ :actioncontroller, :actionview, :activerecord, :excon, :memcache, :'net-http', :rack, :render, :'rpc-client', :'rpc-server', :'sidekiq-client', :'sidekiq-worker', - :redis, :'resque-client', :'resque-worker' ].freeze - ENTRY_SPANS = [ :rack, :'resque-worker', :'rpc-server', :'sidekiq-worker' ].freeze + :redis, :'resque-client', :'resque-worker', :'graphql.server' ].freeze + ENTRY_SPANS = [ :rack, :'resque-worker', :'rpc-server', :'sidekiq-worker', :'graphql.server' ].freeze EXIT_SPANS = [ :activerecord, :excon, :'net-http', :'resque-client', :'rpc-client', :'sidekiq-client', :redis ].freeze HTTP_SPANS = [ :rack, :excon, :'net-http' ].freeze attr_accessor :parent @@ -55,13 +55,10 @@ else @data[:ts] = start_time end if ::Instana.config[:collect_backtraces] - # For entry spans, add a backtrace fingerprint - add_stack(limit: 2) if ENTRY_SPANS.include?(name) - # Attach a backtrace to all exit spans add_stack if EXIT_SPANS.include?(name) end # Check for custom tracing @@ -74,30 +71,37 @@ # Adds a backtrace to this span # # @param limit [Integer] Limit the backtrace to the top <limit> frames # - def add_stack(limit: nil, stack: Kernel.caller) + def add_stack(limit: 30, stack: Kernel.caller) frame_count = 0 + sanitized_stack = [] @data[:stack] = [] + limit = 40 if limit > 40 stack.each do |i| # If the stack has the full instana gem version in it's path # then don't include that frame. Also don't exclude the Rack module. if !i.match(/instana\/instrumentation\/rack.rb/).nil? || (i.match(::Instana::VERSION_FULL).nil? && i.match('lib/instana/').nil?) - break if limit && frame_count >= limit - x = i.split(':') - @data[:stack] << { + sanitized_stack << { :c => x[0], :n => x[1], :m => x[2] } - frame_count = frame_count + 1 if limit end + end + + if sanitized_stack.length > limit + # (limit * -1) gives us negative form of <limit> used for + # slicing from the end of the list. e.g. stack[-30, 30] + @data[:stack] = sanitized_stack[limit*-1, limit] + else + @data[:stack] = sanitized_stack end end # Log an error into the span #