Sha256: 25c74664a9ae3b294c39c87cb6333887bce9e921bc8f9dfaf4459948eb116bc9
Contents?: true
Size: 1.24 KB
Versions: 10
Compression:
Stored size: 1.24 KB
Contents
# frozen_string_literal: true module ElasticAPM # @api private class ErrorBuilder def initialize(config) @config = config end def build_exception(exception, handled: true) error = Error.new error.exception = Error::Exception.new(exception, handled: handled) add_stacktrace error, :exception, exception.backtrace add_transaction_id error if (transaction = ElasticAPM.current_transaction) error.context = transaction.context.dup end error end def build_log(message, backtrace: nil, **attrs) error = Error.new error.log = Error::Log.new(message, **attrs) add_stacktrace error, :log, backtrace add_transaction_id error error end private def add_stacktrace(error, kind, backtrace) return unless (stacktrace = Stacktrace.build(@config, backtrace, :error)) case kind when :exception error.exception.stacktrace = stacktrace when :log error.log.stacktrace = stacktrace end error.culprit = stacktrace.frames.first.function end def add_transaction_id(error) return unless (transaction = ElasticAPM.current_transaction) error.transaction_id = transaction.id end end end
Version data entries
10 entries across 10 versions & 1 rubygems