Class: Hooks::Plugins::Instruments::StatsBase Abstract

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

Overview

This class is abstract.

Subclass and implement service-specific metrics methods

Base class for all stats instrument plugins

This class provides the foundation for implementing custom metrics reporting instruments. Subclasses should implement specific methods for their target metrics service (DataDog, New Relic, StatsD, etc.).

Examples:

Implementing a custom stats instrument

class MyStatsImplementation < Hooks::Plugins::Instruments::StatsBase
  def increment(metric_name, tags = {})
    # Send increment metric to your service
    MyMetricsService.increment(metric_name, tags)
    log.debug("Sent increment metric: #{metric_name}")
  end

  def timing(metric_name, duration, tags = {})
    # Send timing metric to your service
    MyMetricsService.timing(metric_name, duration, tags)
  end
end

See Also:

Direct Known Subclasses

Stats

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

#gauge(metric_name, value, tags = {}) ⇒ void

Note:

Subclasses should implement this method for their specific service

This method returns an undefined value.

Record a gauge metric

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

Examples:

Override in subclass

def gauge(metric_name, value, tags = {})
  statsd.gauge(metric_name, value, tags: tags)
end

Parameters:

  • metric_name (String)

    Name of the gauge metric

  • value (Numeric)

    Current value for the gauge

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

    Optional tags/labels for the metric



82
83
84
# File 'lib/hooks/plugins/instruments/stats_base.rb', line 82

def gauge(metric_name, value, tags = {})
  # No-op implementation for base class
end

#increment(metric_name, tags = {}) ⇒ void

Note:

Subclasses should implement this method for their specific service

This method returns an undefined value.

Record an increment metric

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

Examples:

Override in subclass

def increment(metric_name, tags = {})
  statsd.increment(metric_name, tags: tags)
end

Parameters:

  • metric_name (String)

    Name of the metric to increment

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

    Optional tags/labels for the metric



46
47
48
# File 'lib/hooks/plugins/instruments/stats_base.rb', line 46

def increment(metric_name, tags = {})
  # No-op implementation for base class
end

#timing(metric_name, duration, tags = {}) ⇒ void

Note:

Subclasses should implement this method for their specific service

This method returns an undefined value.

Record a timing/duration metric

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

Examples:

Override in subclass

def timing(metric_name, duration, tags = {})
  statsd.timing(metric_name, duration, tags: tags)
end

Parameters:

  • metric_name (String)

    Name of the timing metric

  • duration (Numeric)

    Duration value (typically in milliseconds)

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

    Optional tags/labels for the metric



64
65
66
# File 'lib/hooks/plugins/instruments/stats_base.rb', line 64

def timing(metric_name, duration, tags = {})
  # No-op implementation for base class
end