BeamConsole.Recorder.History (beam_console v0.5.3)

Copy Markdown View Source

Implements immutable, bounded storage for compact flight-recorder values.

History rejects stale sequences, starts a new segment across sequence gaps, and enforces age, count, and estimated-byte limits on every append. It never stores historical runtime snapshots.

Summary

Functions

Appends one committed frame plus bounded lifecycle events.

Appends direct lifecycle events to the current segment under every history bound.

Creates empty history under validated recorder configuration.

Removes expired values and reapplies all hard limits at the supplied monotonic time.

Returns scalar usage and omission counters for recorder health reporting.

Types

append_result()

@type append_result() :: {:ok, t()} | {:stale, t()}

size_estimator()

@type size_estimator() :: (map() -> non_neg_integer())

t()

@type t() :: %BeamConsole.Recorder.History{
  config: BeamConsole.Recorder.Config.t(),
  dropped_events: non_neg_integer(),
  dropped_frames: non_neg_integer(),
  estimated_bytes: non_neg_integer(),
  events: [BeamConsole.Lifecycle.Event.t()],
  frames: [BeamConsole.Recorder.Frame.t()],
  last_sequence: non_neg_integer() | nil,
  segment: non_neg_integer()
}

Functions

append(history, frame, events \\ [], options \\ [])

Appends one committed frame plus bounded lifecycle events.

Duplicate or older frame sequences return {:stale, history} without mutation. Pass reset?: true to start a new correlation segment explicitly. Tests may inject :now_ms and a deterministic unary :size_estimator.

append_events(history, events, options \\ [])

@spec append_events(t(), [BeamConsole.Lifecycle.Event.t()], keyword()) :: t()

Appends direct lifecycle events to the current segment under every history bound.

new(config \\ Config.defaults())

@spec new(BeamConsole.Recorder.Config.t()) :: t()

Creates empty history under validated recorder configuration.

Examples

iex> history = BeamConsole.Recorder.History.new()
iex> BeamConsole.Recorder.History.stats(history).frame_count
0

prune(history, now_ms, estimator \\ :default)

@spec prune(t(), integer(), size_estimator() | :default) :: t()

Removes expired values and reapplies all hard limits at the supplied monotonic time.

stats(history)

@spec stats(t()) :: map()

Returns scalar usage and omission counters for recorder health reporting.