ElixirScope.Storage.DataAccess (elixir_scope v0.0.1)
High-performance ETS-based storage for ElixirScope events.
Provides multiple indexes for fast querying across different dimensions:
- Primary index: Event ID -> Event
- Temporal index: Timestamp -> Event ID
- Process index: PID -> [Event IDs]
- Function index: {Module, Function} -> [Event IDs]
- Correlation index: Correlation ID -> [Event IDs]
Designed for high write throughput and fast range queries.
Summary
Functions
Cleans up old events to maintain memory bounds.
Destroys the storage and cleans up all ETS tables.
Checks if an event exists by ID.
Retrieves an event by its ID.
Queries events since a given timestamp.
Gets the current instrumentation plan.
Gets storage statistics.
Creates a new data access instance with ETS tables.
Queries events by correlation ID.
Queries events by function.
Queries events by process ID.
Queries events by time range.
Stores an event in the data access layer.
Stores multiple events (simplified interface).
Stores multiple events in batch for better performance.
Stores an instrumentation plan.
Types
Functions
@spec cleanup_old_events(t(), non_neg_integer()) :: {:ok, non_neg_integer()} | {:error, term()}
Cleans up old events to maintain memory bounds.
Removes events older than the specified timestamp.
@spec destroy(t()) :: :ok
Destroys the storage and cleans up all ETS tables.
Checks if an event exists by ID.
Retrieves an event by its ID.
@spec get_events_since(non_neg_integer()) :: [ElixirScope.Events.event()]
Queries events since a given timestamp.
@spec get_instrumentation_plan() :: {:ok, map()} | {:error, :not_found}
Gets the current instrumentation plan.
@spec get_stats(t()) :: %{ total_events: non_neg_integer(), max_events: non_neg_integer(), oldest_timestamp: non_neg_integer() | nil, newest_timestamp: non_neg_integer() | nil, memory_usage: non_neg_integer() }
Gets storage statistics.
Creates a new data access instance with ETS tables.
Options
:name
- Base name for the tables (default: generates unique name):max_events
- Maximum number of events to store (default: 1_000_000)
@spec query_by_correlation(t(), term(), query_options()) :: {:ok, [ElixirScope.Events.event()]} | {:error, term()}
Queries events by correlation ID.
@spec query_by_function(t(), module(), atom(), query_options()) :: {:ok, [ElixirScope.Events.event()]} | {:error, term()}
Queries events by function.
@spec query_by_process(t(), pid(), query_options()) :: {:ok, [ElixirScope.Events.event()]} | {:error, term()}
Queries events by process ID.
@spec query_by_time_range(t(), non_neg_integer(), non_neg_integer(), query_options()) :: {:ok, [ElixirScope.Events.event()]} | {:error, term()}
Queries events by time range.
Options
:limit
- Maximum number of events to return (default: 1000):order
-:asc
or:desc
(default::asc
)
Stores an event in the data access layer.
Automatically creates all necessary indexes for fast querying.
@spec store_events([ElixirScope.Events.event()]) :: :ok | {:error, term()}
Stores multiple events (simplified interface).
@spec store_events(t(), [ElixirScope.Events.event()]) :: {:ok, non_neg_integer()} | {:error, term()}
Stores multiple events in batch for better performance.
Stores an instrumentation plan.