Class: Hooks::Plugins::Instruments::FailbotBase Abstract

Inherits:
Object
  • Object
show all
Includes:
Core::ComponentAccess
Defined in:
lib/hooks/plugins/instruments/failbot_base.rb

Overview

This class is abstract.

Subclass and implement service-specific error reporting methods

Base class for all failbot instrument plugins

This class provides the foundation for implementing custom error reporting instruments. Subclasses should implement specific methods for their target error reporting service (Sentry, Rollbar, Honeybadger, etc.).

Examples:

Implementing a custom failbot instrument

class MySentryFailbot < Hooks::Plugins::Instruments::FailbotBase
  def report(error_or_message, context = {})
    case error_or_message
    when Exception
      Sentry.capture_exception(error_or_message, extra: context)
    else
      Sentry.capture_message(error_or_message.to_s, extra: context)
    end
    log.debug("Reported error to Sentry")
  end
end

See Also:

Direct Known Subclasses

Failbot

Instance Method Summary collapse

Methods included from Core::ComponentAccess

#failbot, #log, #method_missing, #respond_to_missing?, #stats

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Hooks::Core::ComponentAccess

Instance Method Details

#report(error_or_message, context = {}) ⇒ void

Note:

Subclasses should implement this method for their specific service

This method returns an undefined value.

Report an error or message to the error tracking service

This is a no-op implementation that subclasses should override to provide actual error reporting functionality.

Examples:

Override in subclass

def report(error_or_message, context = {})
  if error_or_message.is_a?(Exception)
    ErrorService.report_exception(error_or_message, context)
  else
    ErrorService.report_message(error_or_message, context)
  end
end

Parameters:

  • error_or_message (Exception, String)

    The error to report or message string

  • context (Hash) (defaults to: {})

    Additional context information about the error



49
50
51
# File 'lib/hooks/plugins/instruments/failbot_base.rb', line 49

def report(error_or_message, context = {})
  # No-op implementation for base class
end

#warn(message, context = {}) ⇒ void

Note:

Subclasses should implement this method for their specific service

This method returns an undefined value.

Report a warning-level message

This is a no-op implementation that subclasses should override to provide actual warning reporting functionality.

Examples:

Override in subclass

def warn(message, context = {})
  ErrorService.report_warning(message, context)
end

Parameters:

  • message (String)

    Warning message to report

  • context (Hash) (defaults to: {})

    Additional context information



66
67
68
# File 'lib/hooks/plugins/instruments/failbot_base.rb', line 66

def warn(message, context = {})
  # No-op implementation for base class
end