BoundedAuthorityReportAdapter. Telemetry
(Bounded Authority Report Adapter v0.3.0)
Copy Markdown
View Source
The closed, value-free telemetry surface for the four signing entry points.
The library emits events but does NOT attach a handler — a fresh application
sees nothing until it attaches one (:telemetry.attach/4 or a
Telemetry.Metrics reporter; docs/telemetry.md carries the runnable
example). What is emitted is deliberately tiny:
[:bounded_authority_report_adapter, :sign, :start]— measurements%{count: 1}, metadata%{object: object}.[:bounded_authority_report_adapter, :sign, :stop]— measurements%{duration: native_monotonic_delta}, metadata%{object: object, result_class: class}.
The value-free invariant (a named misuse)
Metadata carries exactly two closed atoms and NOTHING else — never key ids,
thumbprints, message bytes, report content, caller opts, or error VALUES
({:producer_error, :invalid} is the class :producer_error, full stop; a
wrong-key failure is :signing_failed, not the keys involved). Adding a
value-carrying field to an emission is a named MISUSE of this surface, not an
extension: the emitters are shape-validated (emit_start/1, emit_stop/3)
and REFUSE anything outside the closed shapes with
{:error, :telemetry_invalid} rather than emitting it.
Telemetry never outranks the signature
sign_span/2 returns the signer's result UNCHANGED. A failure inside the
emission is swallowed ({:error, :telemetry_invalid}); a raise inside the
SIGNER propagates — only the emission is guarded, never the crypto.
Summary
Functions
The closed result-class axis (the classified outcome of a signing span).
Emits [:bounded_authority_report_adapter, :sign, :start] with
%{count: 1} / %{object: object}. Refuses an unknown object with
{:error, :telemetry_invalid} instead of emitting garbage.
Emits [:bounded_authority_report_adapter, :sign, :stop] with
%{duration: duration} / %{object: object, result_class: result_class}.
Refuses an unknown object or class, or a non-nonnegative-integer duration,
with {:error, :telemetry_invalid} instead of emitting garbage — this
validation is the mechanical value-free guarantee: a metadata key outside
the closed shape is not expressible through this emitter.
The closed object axis (one atom per signing entry point).
Runs fun inside a :sign span: emits :start, runs it, emits :stop
with the monotonic duration and the classified result, and returns whatever
fun returned — unchanged. object must be one of objects/0.
Functions
@spec classes() :: [atom()]
The closed result-class axis (the classified outcome of a signing span).
@spec emit_start(atom()) :: :ok | {:error, :telemetry_invalid}
Emits [:bounded_authority_report_adapter, :sign, :start] with
%{count: 1} / %{object: object}. Refuses an unknown object with
{:error, :telemetry_invalid} instead of emitting garbage.
Emits [:bounded_authority_report_adapter, :sign, :stop] with
%{duration: duration} / %{object: object, result_class: result_class}.
Refuses an unknown object or class, or a non-nonnegative-integer duration,
with {:error, :telemetry_invalid} instead of emitting garbage — this
validation is the mechanical value-free guarantee: a metadata key outside
the closed shape is not expressible through this emitter.
@spec objects() :: [atom()]
The closed object axis (one atom per signing entry point).
Runs fun inside a :sign span: emits :start, runs it, emits :stop
with the monotonic duration and the classified result, and returns whatever
fun returned — unchanged. object must be one of objects/0.
Telemetry failures are swallowed inside the emitters; a raise inside fun
propagates (the emission is guarded, the crypto is not).