Anvil.Telemetry.Alerts (Anvil v0.1.1)

View Source

Alerting hooks for critical Anvil telemetry events.

Provides configurable alerting for:

  • Low agreement scores (quality degradation)
  • Queue backup (throughput issues)
  • Export failures (operational issues)
  • Assignment timeout spikes (policy issues)

Usage

Attach alerting handlers in your application supervisor:

def start(_type, _args) do
  children = [
    # ... other children
  ]

  # Attach alert handlers after supervisor starts
  :ok = Anvil.Telemetry.Alerts.attach_handlers()

  Supervisor.start_link(children, strategy: :one_for_one)
end

Configuration

config :anvil, :alerts,
  enabled: true,
  low_agreement_threshold: 0.4,
  queue_backup_threshold: 100,
  timeout_spike_threshold: 50,
  timeout_spike_window: :hour,
  handlers: [
    log: true,
    slack: [enabled: false, webhook_url: nil],
    pagerduty: [enabled: false, api_key: nil]
  ]

Summary

Functions

Attaches telemetry handlers for alerting.

Detaches telemetry handlers for alerting.

Functions

attach_handlers()

@spec attach_handlers() :: :ok

Attaches telemetry handlers for alerting.

Call this once during application startup, typically in Application.start/2.

detach_handlers()

@spec detach_handlers() :: :ok | {:error, :not_found}

Detaches telemetry handlers for alerting.