class ElasticAPM::ErrorBuilder

def add_stacktrace(error, kind, backtrace)

def add_stacktrace(error, kind, backtrace)
  stacktrace =
    @agent.stacktrace_builder.build(backtrace, type: :error)
  return unless stacktrace
  case kind
  when :exception
    error.exception.stacktrace = stacktrace
  when :log
    error.log.stacktrace = stacktrace
  end
  error.culprit = stacktrace.frames.first&.function
end