Telemetry integration helpers for Threadline.
Threadline emits four telemetry events:
[:threadline, :transaction, :committed]— after anAuditTransactionis committed. Automatically emitted (withtable_count: 0) whenThreadline.record_action/2succeeds. For accurate per-transaction counts, callThreadline.Telemetry.transaction_committed/2explicitly after a known DB transaction commit.[:threadline, :action, :recorded]— afterThreadline.record_action/2completes (success or failure).[:threadline, :health, :checked]— afterThreadline.Health.trigger_coverage/1returns. Measurements:%{covered: integer, uncovered: integer, expected_uncovered: integer}. Theexpected_uncoveredmeasurement was added in Phase 66 (additive — subscribers that destructure onlycoveredanduncoveredkeep working).[:threadline, :health, :checked, :error]— sibling event emitted when a polled coverage check raises (Phase 66 D-30c). Metadata:%{error: message}. The dashboard keeps the last-good snapshot and reschedules the next poll; this event lets adopters alert on transient or sustained failure.
Usage
Attach handlers in your application's start/2 callback:
:telemetry.attach(
"my-app-audit",
[:threadline, :action, :recorded],
&MyApp.Instrumentation.handle_event/4,
nil
)
Summary
Functions
Emits the [:threadline, :health, :checked] event with covered / uncovered /
expected_uncovered measurements.
Emits the [:threadline, :health, :checked, :error] event when a polled
coverage check fails (Phase 66 D-30c). The dashboard keeps the last-good
snapshot and ALWAYS reschedules the next poll; this event lets adopters
alert on transient or sustained failure.
Emits [:threadline, :transaction, :committed] with the given table count.
Functions
Emits the [:threadline, :health, :checked] event with covered / uncovered /
expected_uncovered measurements.
Phase 66 added the expected_uncovered measurement key (additive). External
subscribers that destructure only %{covered: c, uncovered: u} continue to
work unchanged.
Emits the [:threadline, :health, :checked, :error] event when a polled
coverage check fails (Phase 66 D-30c). The dashboard keeps the last-good
snapshot and ALWAYS reschedules the next poll; this event lets adopters
alert on transient or sustained failure.
Emits [:threadline, :transaction, :committed] with the given table count.
Call this after a DB transaction that you know produced AuditTransaction
records, when you need accurate table_count measurements.
Example
{:ok, txn} = MyApp.Repo.transaction(fn ->
# ... your writes ...
end)
Threadline.Telemetry.transaction_committed(txn, table_count: 3)