Sha256: 9e8cfb5b8b92f830d72c69cef8df86101f4122cf803d36e82cd546f799465977
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
# frozen_string_literal: true module ElasticAPM # @api private class ErrorBuilder def initialize(config) @config = config end attr_reader :config 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)) case kind when :exception error.exception.stacktrace = stacktrace when :log error.log.stacktrace = stacktrace end error.culprit = stacktrace.frames.last.function end def add_transaction_id(error) return unless (transaction = ElasticAPM.current_transaction) error.transaction_id = transaction.id end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
elastic-apm-0.2.0 | lib/elastic_apm/error_builder.rb |