Internal module. Not part of TraceGuard's public API: it may change in
any release. Use the functions in TraceGuard instead.
A bounded record of recent report drops, and of submissions that were accepted but are not yet stored.
It is used by TraceGuard.report_status/1 and TraceGuard.await_report/2
to tell a report that was dropped apart from one that is pending
or simply not observed.
What is recorded
- Drops:
{trace_id, reason}, recorded when the storage facade or an adapter reports one (TraceGuard.Storage.dropped/2), includingreason: :lostfor submissions that were accepted but died with a crashed store. Nothing else about the request is stored. Reasons are normalized to atoms, small tuples of atoms, integers and short strings; anything else becomes:other. - Pending: trace IDs submitted to an adapter that queues reports, removed as soon as the report is stored or dropped.
Bounds and expiry
- At most
:max_drop_recordsdrop records (default 1000). The oldest is evicted first. Under concurrent writers, racing evictions can leave the count below the limit, by up to the number of concurrent writers (41 of 50 has been observed with 64 writers). It is never above the limit for longer than one insert. - A drop record expires after
:drop_record_ttlms (default 600_000), measured with the monotonic clock. Expired records are treated as absent on lookup and removed by a periodic sweep. - At most
:max_drop_recordspending entries. Pending entries older than:drop_record_ttlare removed (not turned into drops: a missing outcome is never reported as a drop).
An expired or evicted record means "unknown", never "not dropped". The absence of a record is not evidence of anything.
Concurrency
The tables are public ETS tables owned by this process. Writers (request processes, store processes) insert directly, so there is no mailbox in the write path. If this process restarts, its records are lost and lookups answer "unknown" for them.
Summary
Functions
Returns a specification to start this module under a supervisor.
{:dropped, reason} if a live drop record exists, else :none.
For a restarted adapter: every submission still pending for adapter was
lost with the previous incarnation. Records each as a :lost drop and
returns how many there were.
Marks trace_id as submitted to adapter and awaiting an outcome.
True while trace_id was submitted and has no outcome yet.
Records that trace_id's report was dropped for reason.
Clears the pending mark of trace_id (stored, or refused synchronously).
Current table sizes.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
{:dropped, reason} if a live drop record exists, else :none.
@spec lost_pending(module()) :: non_neg_integer()
For a restarted adapter: every submission still pending for adapter was
lost with the previous incarnation. Records each as a :lost drop and
returns how many there were.
Marks trace_id as submitted to adapter and awaiting an outcome.
True while trace_id was submitted and has no outcome yet.
Records that trace_id's report was dropped for reason.
@spec resolve(String.t()) :: :ok
Clears the pending mark of trace_id (stored, or refused synchronously).
@spec sizes() :: %{drop_records: non_neg_integer(), pending: non_neg_integer()}
Current table sizes.