ADK.Telemetry.SpanStore (ADK v0.0.1-alpha.1)

Copy Markdown View Source

ETS-backed store for debug/trace span data.

Stores span data in two ETS tables:

  • adk_event_spans — keyed by event_id, stores span attributes
  • adk_session_spans — keyed by session_id, stores lists of span data

Provides the backing store for the /debug/trace/ HTTP endpoints that match Python ADK's debug API.

TTL

Entries are automatically pruned after a configurable max age (default 30 minutes). Configure via application env:

config :adk, :span_store_ttl_ms, 1_800_000

Usage

ADK.Telemetry.SpanStore.put_event_span("evt-123", %{name: "agent.run", ...})
ADK.Telemetry.SpanStore.get_event_span("evt-123")
#=> {:ok, %{name: "agent.run", ...}}

ADK.Telemetry.SpanStore.put_session_span("sess-1", %{name: "agent.run", ...})
ADK.Telemetry.SpanStore.get_session_spans("sess-1")
#=> [%{name: "agent.run", ...}]

Summary

Functions

Returns a specification to start this module under a supervisor.

Clear all stored spans (useful for testing).

Retrieve span attributes for an event_id.

Retrieve all spans for a session_id.

Store span attributes keyed by event_id.

Store a span for a session_id (appended to existing list).

Start the SpanStore as part of a supervision tree.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

clear()

@spec clear() :: :ok

Clear all stored spans (useful for testing).

get_event_span(event_id)

@spec get_event_span(String.t()) :: {:ok, map()} | :not_found

Retrieve span attributes for an event_id.

get_session_spans(session_id)

@spec get_session_spans(String.t()) :: [map()]

Retrieve all spans for a session_id.

put_event_span(event_id, attrs)

@spec put_event_span(String.t(), map()) :: :ok

Store span attributes keyed by event_id.

put_session_span(session_id, span_data)

@spec put_session_span(String.t(), map()) :: :ok

Store a span for a session_id (appended to existing list).

start_link(opts \\ [])

Start the SpanStore as part of a supervision tree.