DoubleEntryLedger.Telemetry (double_entry_ledger v0.3.0)
View SourceTelemetry events emitted by DoubleEntryLedger.
All events use the [:double_entry_ledger, ...] prefix. The library emits
events but does not attach handlers — consumers attach their own handlers
at application boot.
Event Catalog
Span Events (automatic start/stop/exception with duration)
| Event prefix | Description |
|---|---|
[:double_entry_ledger, :command, :process] | Command processing lifecycle |
Point Events
| Event | Description |
|---|---|
[:double_entry_ledger, :command, :enqueue] | Command persisted to queue |
[:double_entry_ledger, :command, :claim] | Command claimed by processor |
[:double_entry_ledger, :command, :retry] | Command scheduled for retry |
[:double_entry_ledger, :command, :dead_letter] | Command permanently failed |
[:double_entry_ledger, :command, :idempotency_hit] | Duplicate command detected |
[:double_entry_ledger, :occ, :retry] | OCC retry attempt |
[:double_entry_ledger, :transaction, :created] | Transaction created |
[:double_entry_ledger, :transaction, :posted] | Transaction posted |
[:double_entry_ledger, :transaction, :archived] | Transaction archived |
[:double_entry_ledger, :account, :created] | Account created |
[:double_entry_ledger, :account, :updated] | Account updated |
[:double_entry_ledger, :instance, :created] | Instance created |
[:double_entry_ledger, :instance_processor, :start] | Instance processor started |
[:double_entry_ledger, :instance_processor, :stop] | Instance processor stopped |
Phoenix LiveDashboard Integration
If telemetry_metrics is available, call dashboard_metrics/0 to get a list
of recommended Telemetry.Metrics definitions:
def metrics do
MyApp.my_metrics() ++ DoubleEntryLedger.Telemetry.dashboard_metrics()
end
Summary
Functions
Emits an account created event.
Emits an account updated event.
Emits a command claim event.
Emits a command dead letter event.
Emits a command enqueue event.
Emits a command idempotency hit event.
Wraps command processing in a telemetry span.
Emits a command retry event.
Returns a list of recommended Telemetry.Metrics definitions for Phoenix LiveDashboard.
Emits the appropriate account lifecycle event based on whether the account was just created or updated.
Emits the appropriate transaction lifecycle event based on the transaction's state.
Emits an instance created event.
Emits an instance processor start event.
Emits an instance processor stop event.
Emits an OCC retry event.
Emits a transaction archived event.
Emits a transaction created event.
Emits a transaction posted event.
Functions
@spec account_created(map()) :: :ok
Emits an account created event.
Metadata
:account_address- Account address:instance_id- Ledger instance UUID:type- Account type (:asset,:liability, etc.):currency- Account currency atom:trace_context- Consumer-supplied tracing context (map or nil)
@spec account_updated(map()) :: :ok
Emits an account updated event.
Metadata
:account_address- Account address:instance_id- Ledger instance UUID:trace_context- Consumer-supplied tracing context (map or nil)
@spec command_claim(map()) :: :ok
Emits a command claim event.
Metadata
:command_id- Command UUID:instance_id- Ledger instance UUID:processor_id- Processor identifier string:trace_context- Consumer-supplied tracing context (map or nil)
@spec command_dead_letter(map()) :: :ok
Emits a command dead letter event.
Metadata
:command_id- Command UUID:instance_id- Ledger instance UUID:error- Reason for dead-lettering:trace_context- Consumer-supplied tracing context (map or nil)
@spec command_enqueue(map()) :: :ok
Emits a command enqueue event.
Metadata
:action- Command action atom:instance_id- Ledger instance UUID:source- Source system identifier:trace_context- Consumer-supplied tracing context (map or nil)
@spec command_idempotency_hit(map()) :: :ok
Emits a command idempotency hit event.
Metadata
:action- Command action atom:instance_id- Ledger instance UUID:source- Source system identifier:source_idempk- Idempotency key that was duplicated:trace_context- Consumer-supplied tracing context (map or nil)
Wraps command processing in a telemetry span.
Emits [:double_entry_ledger, :command, :process, :start],
[:double_entry_ledger, :command, :process, :stop], and
[:double_entry_ledger, :command, :process, :exception] events.
Parameters
metadata- Map with:action,:instance_id,:source,:trace_contextfun- Zero-arity function to execute within the span
Returns
The return value of fun.
@spec command_retry(map()) :: :ok
Emits a command retry event.
Metadata
:command_id- Command UUID:instance_id- Ledger instance UUID:status- Status being set (:failed,:occ_timeout):retry_count- Current retry count:trace_context- Consumer-supplied tracing context (map or nil)
@spec dashboard_metrics() :: [Telemetry.Metrics.t()]
Returns a list of recommended Telemetry.Metrics definitions for Phoenix LiveDashboard.
Add these to your application's telemetry module:
def metrics do
MyApp.my_metrics() ++ DoubleEntryLedger.Telemetry.dashboard_metrics()
endThen reference it in your LiveDashboard route:
live_dashboard "/dashboard", metrics: MyAppWeb.TelemetryRequires the optional telemetry_metrics dependency.
@spec emit_account(Ecto.Schema.t(), map() | nil) :: :ok
Emits the appropriate account lifecycle event based on whether the account was just created or updated.
Dispatches to account_created/1 or account_updated/1 based on whether
the account has been modified since creation (via inserted_at == updated_at).
Parameters
account- TheAccountstructtrace_context- Consumer-supplied tracing context (map or nil)
@spec emit_transaction(Ecto.Schema.t(), map() | nil) :: :ok
Emits the appropriate transaction lifecycle event based on the transaction's state.
Dispatches to transaction_created/1, transaction_posted/1, or
transaction_archived/1 based on the transaction's status and whether it
has been modified since creation (via inserted_at == updated_at).
Parameters
transaction- TheTransactionstructtrace_context- Consumer-supplied tracing context (map or nil)
@spec instance_created(map()) :: :ok
Emits an instance created event.
Metadata
:instance_id- Instance UUID
@spec instance_processor_start(map()) :: :ok
Emits an instance processor start event.
Metadata
:instance_id- Instance UUID being processed
@spec instance_processor_stop(map()) :: :ok
Emits an instance processor stop event.
Metadata
:instance_id- Instance UUID that was being processed
@spec occ_retry(map()) :: :ok
Emits an OCC retry event.
Metadata
:module- Processor module handling the command:attempts_remaining- Retry attempts left:command_id- Command UUID (nil on synchronous path):instance_id- Ledger instance UUID:action- Command action atom:source- Source system identifier:source_idempk- Source idempotency key:trace_context- Consumer-supplied tracing context (map or nil)
@spec transaction_archived(map()) :: :ok
Emits a transaction archived event.
Metadata
:transaction_id- Transaction UUID:instance_id- Ledger instance UUID:trace_context- Consumer-supplied tracing context (map or nil)
@spec transaction_created(map()) :: :ok
Emits a transaction created event.
Metadata
:transaction_id- Transaction UUID:instance_id- Ledger instance UUID:status- Initial status (:pendingor:posted):trace_context- Consumer-supplied tracing context (map or nil)
@spec transaction_posted(map()) :: :ok
Emits a transaction posted event.
Metadata
:transaction_id- Transaction UUID:instance_id- Ledger instance UUID:trace_context- Consumer-supplied tracing context (map or nil)