Class: StackifyRubyAPM::ErrorBuilder Private

Inherits:
Object
  • Object
show all
Defined in:
lib/stackify_apm/error_builder.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(agent) ⇒ ErrorBuilder

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ErrorBuilder.



8
9
10
# File 'lib/stackify_apm/error_builder.rb', line 8

def initialize(agent)
  @agent = agent
end

Instance Method Details

#build_exception(exception, handled: true) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/stackify_apm/error_builder.rb', line 12

def build_exception(exception, handled: true)
  error = Error.new
  error.exception = Error::Exception.new(exception, handled: handled)

  if exception
    backtrace_identifier = :backtrace
    backtrace = nil

    if exception.respond_to?(:backtrace_identifier, true)
      backtrace = exception.send(:backtrace_identifier)
    end

    add_stacktrace error, :exception, backtrace
  end

  add_transaction_id error

  if (transaction = StackifyRubyAPM.current_transaction)
    error.context = transaction.context.dup
  end

  error
end

#build_log(message, backtrace: nil, **attrs) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



36
37
38
39
40
41
42
43
44
# File 'lib/stackify_apm/error_builder.rb', line 36

def build_log(message, backtrace: nil, **attrs)
  error = Error.new
  error.log = Error::Log.new(message, **attrs)

  add_stacktrace error, :log, backtrace if backtrace
  add_transaction_id error

  error
end