# `OpentelemetryStatifier.Persistence.Handler`
[🔗](https://github.com/riddler/opentelemetry_statifier/blob/v0.10.0/lib/opentelemetry_statifier/persistence/handler.ex#L1)

The `:telemetry` handler attached to every name
`OpentelemetryStatifier.Persistence.events/0` returns.

Same defensive posture as `OpentelemetryStatifier.Handler`, for the
same reason: no `try`/`rescue`, because `:telemetry` detaches a raising
handler for the VM's lifetime and the per-event handler ids bound that
loss to one event name. What this module owes instead is clause
exhaustiveness - every clause binds only the keys it needs, and a
malformed event falls through to the catch-all and drops a span rather
than raising inside a host's durable step.

Three shapes, decided by the contract rather than by this module
(`statifier_persistence`'s `docs/telemetry.md`):

  * the step seam and the batch migration seam are pairs, and each
    becomes a span: `:start` opens it and exactly one of `:stop` or
    `:exception` closes it, the latter with an error status;
  * `[..., :adapter, :call]` and `[..., :execution, :lock]` are points that
    carry a `duration`, and become spans back-dated by it, an adapter
    call only inside an enclosing span unless the config's
    `adapter_calls` is `:all`;
  * everything else is a point, and becomes a span event on the paired
    span open around it (the step or the batch) -
    `[..., :step, :reentered]` included, which has four segments but
    no `span_ref`, and so is a point rather than a half of the pair.

Of the family's three list-valued keys, `:reentered`'s `opts` renders
with `inspect/1` before the attribute rules see it, which would
otherwise drop a list, and `:migrated`'s `dropped` becomes a sorted
string-array attribute, as `configuration` does
(`OpentelemetryStatifier.Persistence`'s moduledoc says why); the third,
`:exception`'s `stacktrace`, is left to the rules and dropped as an
attribute, and travels instead as the `exception.stacktrace` of the
`exception` span event the close records.

# `handle_event`

```elixir
@spec handle_event(
  :telemetry.event_name(),
  map(),
  map(),
  OpentelemetryStatifier.Config.t()
) :: :ok
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
