OpentelemetryStatifier.Handler (OpentelemetryStatifier v0.1.0)

Copy Markdown View Source

The :telemetry handler attached to every name Statifier.Session.Telemetry.events/0 returns.

There is deliberately no try/rescue here. :telemetry itself catches error | exit | throw from a raising handler and detaches it (deps/telemetry/src/telemetry.erl:196-215) - and because OpentelemetryStatifier.setup/1 attaches one handler id per event name (rather than one attach_many/4 id shared across all 27), a raise in one clause only costs that one event name, not the whole bridge, for the rest of the VM's life. The defensive posture this module actually needs is clause exhaustiveness - a final catch-all clause, matching otel_telemetry.erl's own handle_event(_, _, _, _) -> ok. and ecto's defp query_opts(_), do: %{} - not rescue-to-default. Every clause here (the two macrostep clauses, the :init link-capture clause, the :terminate cleanup clause, and the span-event clauses for the effect/trace families plus :interpret/:unroutable/:halt) must bind only the keys it needs in its head, so a malformed or unrecognised event falls through to the catch-all and drops the span (or span event) rather than raising.

Summary

Functions

handle_event(arg1, measurements, metadata, config)

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