Class: Hoss::ErrorBuilder Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hoss/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.

[View source]

23
24
25
# File 'lib/hoss/error_builder.rb', line 23

def initialize(agent)
  @agent = agent
end

Instance Method Details

#build_exception(exception, context: nil, 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.

[View source]

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/hoss/error_builder.rb', line 27

def build_exception(exception, context: nil, handled: true)
  error = Error.new context: context || Context.new
  error.exception =
    Error::Exception.from_exception(exception, handled: handled)

  Util.reverse_merge!(error.context.labels, @agent.config.default_labels)

  if exception.backtrace
    add_stacktrace error, :exception, exception.backtrace
  end

  add_current_transaction_fields error, Hoss.current_transaction

  error
end

#build_log(message, context: nil, 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.

[View source]

43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/hoss/error_builder.rb', line 43

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

  if backtrace
    add_stacktrace error, :log, backtrace
  end

  add_current_transaction_fields error, Hoss.current_transaction

  error
end