Generates Telemetry.Metrics.counter/2 definitions for failure
events.
Two input modes cover 3-segment and 4–5 segment event names.
Shorthand mode (3-segment apps)
For apps where every failure event follows the
[:<app>, :<domain>, :failure] convention:
FosferonTelemetry.FailureMetrics.counters(:my_app, [:session, :checkout, :support])
# => [
# counter("my_app.session.failure.count", tags: [:stage]),
# counter("my_app.checkout.failure.count", tags: [:stage]),
# counter("my_app.support.failure.count", tags: [:stage])
# ]Explicit tuple mode (4–5 segment apps)
For apps with non-standard event structures, pass a list of
{event_name, metric_name} tuples:
FosferonTelemetry.FailureMetrics.counters([
{[:billing, :invoices, :refund, :error],
"billing.invoices.refund.error.count"},
{[:billing, :invoices, :line_items, :create, :error],
"billing.invoices.line_items.create.error.count"}
])Tag discipline
v1 rule: counters use only :stage as a tag. Never tag on IDs,
slugs, or free-text fields — unbounded cardinality kills Prometheus.
Summary
Functions
Generate failure counters in explicit tuple mode.
Generate failure counters in shorthand mode.
Functions
@spec counters([{[atom()], String.t()}]) :: [Telemetry.Metrics.Counter.t()]
Generate failure counters in explicit tuple mode.
Each {event_name, metric_name} tuple maps directly to a counter
definition. Use this for apps whose event names don't follow the
3-segment [:<app>, :<domain>, :failure] convention.
@spec counters(atom(), [atom()]) :: [Telemetry.Metrics.Counter.t()]
Generate failure counters in shorthand mode.
Each domain atom becomes a [:<app>, :<domain>, :failure] event
with metric name "<app>.<domain>.failure.count".