FosferonTelemetry.FailureHandler (fosferon_telemetry v0.1.0)

Copy Markdown View Source

Generic :telemetry handler for apps whose failure events follow the canonical metadata schema: stage, error_class, error_message.

Scoped to 3-segment failure events ([:<app>, :<domain>, :failure]).

Usage

# In your Application.start/2 or a Telemetry supervisor:
FosferonTelemetry.FailureHandler.attach(:my_app, [:session, :checkout, :support])

This attaches a single handler via :telemetry.attach_many/4 that logs all matching events at :warning level with the canonical metadata fields.

Idempotency

attach/2 is idempotent — :already_exists from :telemetry.attach_many/4 is treated as :ok, so application restarts and supervision re-init are safe.

Self-recovery

The handler rescues its own exceptions to prevent :telemetry from detaching it on crash. A crashing handler would silently drop all subsequent failure events for the app.

Summary

Functions

Attach this handler for the given app and domains.

Functions

attach(app, domains)

@spec attach(atom(), [atom()]) :: :ok

Attach this handler for the given app and domains.

Builds events as [:<app>, :<domain>, :failure] for each domain, then attaches a single handler via :telemetry.attach_many/4.

The handler ID follows the convention "<app>-fosferon-failure-handler".