AITrace.Collector (AITrace v0.2.0)

Copy Markdown View Source

Supervised in-memory collector for traces in progress.

The collector stores active traces in one supervised owner per trace id. This state is working memory only; exported traces remain the authoritative proof path.

Summary

Functions

Adds a span to a trace.

Returns false because collector state is in-memory working state only.

Returns a specification to start this module under a supervisor.

Clears all traces from the supervised collector.

Describes the collector evidence posture for release and incident proof.

Retrieves a trace by its trace_id.

Creates a new trace owner and stores the trace.

Removes a trace owner from the collector.

Starts the collector supervisor.

Returns per-trace collector stats.

Updates a span within a trace.

Updates a trace within its supervised owner.

Functions

add_span(trace_id, span)

@spec add_span(String.t(), AITrace.Span.t()) :: :ok | {:error, map()}

Adds a span to a trace.

authoritative_evidence?()

@spec authoritative_evidence?() :: false

Returns false because collector state is in-memory working state only.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

clear()

@spec clear() :: :ok | {:error, :collector_not_started}

Clears all traces from the supervised collector.

evidence_posture()

@spec evidence_posture() :: map()

Describes the collector evidence posture for release and incident proof.

get_trace(trace_id)

@spec get_trace(String.t()) :: AITrace.Trace.t() | nil

Retrieves a trace by its trace_id.

new_trace(trace_id, opts \\ [])

@spec new_trace(
  String.t(),
  keyword()
) :: AITrace.Trace.t()

Creates a new trace owner and stores the trace.

remove_trace(trace_id)

@spec remove_trace(String.t()) :: :ok

Removes a trace owner from the collector.

start_link(opts \\ [])

@spec start_link(keyword()) :: Supervisor.on_start()

Starts the collector supervisor.

stats(trace_id)

@spec stats(String.t()) :: map() | nil

Returns per-trace collector stats.

update_span(trace_id, span_id, update_fn)

@spec update_span(String.t(), String.t(), (AITrace.Span.t() -> AITrace.Span.t())) ::
  :ok

Updates a span within a trace.

update_trace(trace_id, update_fn)

@spec update_trace(String.t(), (AITrace.Trace.t() -> AITrace.Trace.t())) :: :ok

Updates a trace within its supervised owner.