Class: Rage::Telemetry::SpanResult

Inherits:
Struct
  • Object
show all
Defined in:
lib/rage/telemetry/telemetry.rb

Overview

Contains the result of a span execution.

Examples:

class MyTelemetryHandler < Rage::Telemetry::Handler
  handle "controller.action.process", with: :monitor_500

  def monitor_500
    result = yield

    if result.error?
      MyObservabilitySDK.notify("500 Error Detected", result.exception)
    end
  end
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#exceptionException? (readonly)

Returns The exception raised during the span execution, if any.

Returns:

  • (Exception, nil)

    The exception raised during the span execution, if any.



106
107
108
109
110
111
112
113
114
115
116
# File 'lib/rage/telemetry/telemetry.rb', line 106

SpanResult = Struct.new(:exception) do
  # Returns `true` if the span resulted in an error.
  def error?
    !!exception
  end

  # Returns `true` if the span executed successfully.
  def success?
    !error?
  end
end

Instance Method Details

#error?Boolean

Returns true if the span resulted in an error.

Returns:

  • (Boolean)


108
109
110
# File 'lib/rage/telemetry/telemetry.rb', line 108

def error?
  !!exception
end

#success?Boolean

Returns true if the span executed successfully.

Returns:

  • (Boolean)


113
114
115
# File 'lib/rage/telemetry/telemetry.rb', line 113

def success?
  !error?
end