Class: Contrast::Agent::Telemetry::Exception::StackFrame

Inherits:
Base
  • Object
show all
Defined in:
lib/contrast/agent/telemetry/exception/stack_frame.rb

Overview

This class will hold the all the information for the specific exception and will be passed in the Exception message itself

Constant Summary collapse

VALIDATIONS =
{
    function: { required: true, range: 1..256 },
    type: { required: true, range: 1..256 },
    module_name: { required: false, range: 1..256 }
}.cs__freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(function, type) ⇒ StackFrame

Returns a new instance of StackFrame.

Raises:

  • (ArgumentError)


32
33
34
35
36
37
38
# File 'lib/contrast/agent/telemetry/exception/stack_frame.rb', line 32

def initialize function, type
  super()
  @function = function
  @type = type
  @in_contrast = false
  validate(VALIDATIONS)
end

Instance Attribute Details

#functionString (readonly)

Returns the function of the stack trace.

Returns:

  • (String)

    the function of the stack trace



23
24
25
# File 'lib/contrast/agent/telemetry/exception/stack_frame.rb', line 23

def function
  @function
end

#in_contrastBoolean

Returns Is it in contrast.

Returns:

  • (Boolean)

    Is it in contrast



26
27
28
# File 'lib/contrast/agent/telemetry/exception/stack_frame.rb', line 26

def in_contrast
  @in_contrast
end

#module_nameString

Returns:



29
30
31
# File 'lib/contrast/agent/telemetry/exception/stack_frame.rb', line 29

def module_name
  @module_name
end

#typeString (readonly)

Returns The type of the exception itself.

Returns:

  • (String)

    The type of the exception itself



20
21
22
# File 'lib/contrast/agent/telemetry/exception/stack_frame.rb', line 20

def type
  @type
end

Class Method Details

.build(method, type, module_name = nil) ⇒ Object

Parameters:

  • method (String)

    method, triggered the logger on warn/error/fatal

  • type (String)

    the type ( where it occurred )

  • module_name (String, nil) (defaults to: nil)

    Name of the module if any.



56
57
58
59
60
61
# File 'lib/contrast/agent/telemetry/exception/stack_frame.rb', line 56

def build method, type, module_name = nil
  inst = new(method, type)
  inst.module_name = module_name if module_name
  inst.in_contrast = type.include?('lib/contrast')
  inst
end

Instance Method Details

#to_controlled_hashObject

Raises:

  • (ArgumentError)


47
48
49
50
# File 'lib/contrast/agent/telemetry/exception/stack_frame.rb', line 47

def to_controlled_hash
  super
  { function: function, type: type, module: module_name, inContrast: in_contrast }.compact
end