module Aws::Xray::CallerBuilder

Constants

MAX_BACKTRACE_SIZE

Public Instance Methods

call() click to toggle source

Build caller stack trace data. @return [Hash] for metadata

# File lib/aws/xray/caller_builder.rb, line 10
def call
  dir = (Dir.pwd + '/') rescue '/'
  stack = caller

  truncated = [stack.size - MAX_BACKTRACE_SIZE, 0].max
  stack = stack[0..MAX_BACKTRACE_SIZE - 1].map do |s|
    file, line, method_name = s.split(':')
    {
      path: file.sub(dir, ''),
      line: line,
      label: method_name,
    }
  end

  {
    caller: {
      stack: stack,
      truncated: truncated,
    }
  }
end