Module: Fizzy::Hooks

Included in:
ChainHooks, LoggerHooks, NoopHooks
Defined in:
lib/fizzy/hooks.rb

Overview

Interface for observability hooks. Implement this to add logging, metrics, or tracing to HTTP requests.

Examples:

Custom hooks with logging

class LoggingHooks
  include Fizzy::Hooks

  def on_request_start(info)
    puts "Starting #{info.method} #{info.url}"
  end

  def on_request_end(info, result)
    puts "Completed #{info.method} #{info.url} - #{result.status_code} (#{result.duration}s)"
  end
end

client = Fizzy::Client.new(config: config, token_provider: provider, hooks: LoggingHooks.new)

Instance Method Summary collapse

Instance Method Details

#on_operation_end(info, result) ⇒ void

This method returns an undefined value.

Called when a service operation completes (success or failure).

Parameters:



33
34
35
# File 'lib/fizzy/hooks.rb', line 33

def on_operation_end(info, result)
  # Override in implementation
end

#on_operation_start(info) ⇒ void

This method returns an undefined value.

Called when a service operation starts (e.g., boards.list, cards.create).

Parameters:



25
26
27
# File 'lib/fizzy/hooks.rb', line 25

def on_operation_start(info)
  # Override in implementation
end

#on_paginate(url, page) ⇒ void

This method returns an undefined value.

Called when pagination fetches the next page.

Parameters:

  • url (String)

    the next page URL

  • page (Integer)

    the page number



66
67
68
# File 'lib/fizzy/hooks.rb', line 66

def on_paginate(url, page)
  # Override in implementation
end

#on_request_end(info, result) ⇒ void

This method returns an undefined value.

Called when an HTTP request completes (success or failure).

Parameters:



48
49
50
# File 'lib/fizzy/hooks.rb', line 48

def on_request_end(info, result)
  # Override in implementation
end

#on_request_start(info) ⇒ void

This method returns an undefined value.

Called when an HTTP request starts.

Parameters:



40
41
42
# File 'lib/fizzy/hooks.rb', line 40

def on_request_start(info)
  # Override in implementation
end

#on_retry(info, attempt, error, delay) ⇒ void

This method returns an undefined value.

Called when a request is retried.

Parameters:

  • info (RequestInfo)

    request information

  • attempt (Integer)

    the next attempt number

  • error (Exception)

    the error that triggered the retry

  • delay (Float)

    seconds until retry



58
59
60
# File 'lib/fizzy/hooks.rb', line 58

def on_retry(info, attempt, error, delay)
  # Override in implementation
end