ElixirScope.Capture.Ingestor (elixir_scope v0.0.1)
Ultra-fast event ingestor for ElixirScope.
This is the critical hot path for event capture. Every microsecond counts here. Target: <1µs per event processing time.
Key optimizations:
- Direct ring buffer writes with minimal function call overhead
- Pre-allocated event structs where possible
- Inline timestamp generation
- Minimal validation in hot path
- Batch processing for better throughput
Summary
Functions
Measures the ingestion performance for benchmarking.
Creates a pre-configured ingestor for a specific buffer.
Gets the current buffer for runtime components.
Ingests multiple events in batch for improved performance.
Ingests an Ecto query complete event.
Ingests an Ecto query start event.
Ingests an error event.
Ingests a function call event.
Ingests a function return event.
Ingests a generic event from runtime tracing components.
Ingests a GenServer callback complete event.
Ingests a GenServer callback error event.
Ingests a GenServer callback start event.
Ingests a GenServer callback success event.
Ingests LiveView assigns change event.
Ingests LiveView callback event.
Ingests LiveView callback error event.
Ingests LiveView callback success event.
Ingests LiveView event.
Ingests a LiveView handle_event complete event.
Ingests a LiveView handle_event start event.
Ingests a LiveView mount complete event.
Ingests a LiveView mount start event.
Ingests a message send event.
Ingests a node event.
Ingests a partition detected event.
Ingests a performance metric event.
Ingests Phoenix action complete event.
Ingests Phoenix action error event.
Ingests Phoenix action parameters.
Ingests Phoenix action start event.
Ingests Phoenix action success event.
Ingests a Phoenix channel join complete event.
Ingests a Phoenix channel join start event.
Ingests a Phoenix channel message complete event.
Ingests a Phoenix channel message start event.
Ingests a Phoenix controller entry event.
Ingests a Phoenix controller exit event.
Ingests a Phoenix request complete event.
Ingests a Phoenix request start event.
Ingests a process spawn event.
Ingests a state change event.
Sets the current buffer for runtime components.
Validates that ingestion performance meets targets.
Types
@type ingest_result() :: :ok | {:error, term()}
Functions
@spec benchmark_ingestion( ElixirScope.Capture.RingBuffer.t(), ElixirScope.Events.event(), pos_integer() ) :: %{ avg_time_ns: float(), min_time_ns: non_neg_integer(), max_time_ns: non_neg_integer(), total_time_ns: non_neg_integer(), operations: pos_integer() }
Measures the ingestion performance for benchmarking.
Returns timing statistics for the ingestion operation.
@spec create_fast_ingestor(ElixirScope.Capture.RingBuffer.t()) :: (ElixirScope.Events.event() -> ingest_result())
Creates a pre-configured ingestor for a specific buffer.
Returns a function that can be called with minimal overhead for repeated ingestion. This is useful for hot paths where the buffer doesn't change.
@spec get_buffer() :: {:ok, ElixirScope.Capture.RingBuffer.t()} | {:error, :not_initialized}
Gets the current buffer for runtime components.
This allows runtime tracing components to access the shared event buffer.
@spec ingest_batch(ElixirScope.Capture.RingBuffer.t(), [ElixirScope.Events.event()]) :: {:ok, non_neg_integer()} | {:error, term()}
Ingests multiple events in batch for improved performance.
This is more efficient than individual ingestion for large numbers of events to process at once.
@spec ingest_ecto_query_complete( ElixirScope.Capture.RingBuffer.t(), term(), term(), list(), term(), non_neg_integer() ) :: ingest_result()
Ingests an Ecto query complete event.
@spec ingest_ecto_query_start( ElixirScope.Capture.RingBuffer.t(), term(), term(), list(), map(), module() ) :: ingest_result()
Ingests an Ecto query start event.
@spec ingest_error(ElixirScope.Capture.RingBuffer.t(), term(), term(), list()) :: ingest_result()
Ingests an error event.
@spec ingest_function_call( ElixirScope.Capture.RingBuffer.t(), module(), atom(), list(), pid(), term() ) :: ingest_result()
Ingests a function call event.
This is the most common event type and is heavily optimized.
@spec ingest_function_return( ElixirScope.Capture.RingBuffer.t(), term(), non_neg_integer(), term() ) :: ingest_result()
Ingests a function return event.
@spec ingest_generic_event( ElixirScope.Capture.RingBuffer.t(), atom(), map(), pid(), term(), non_neg_integer(), non_neg_integer() ) :: ingest_result()
Ingests a generic event from runtime tracing components.
This function converts runtime trace data into appropriate ElixirScope.Events and forwards them to the existing ingestion pipeline.
@spec ingest_genserver_callback_complete( ElixirScope.Capture.RingBuffer.t(), atom(), pid(), term() ) :: ingest_result()
Ingests a GenServer callback complete event.
@spec ingest_genserver_callback_error( ElixirScope.Capture.RingBuffer.t(), atom(), pid(), atom(), term() ) :: ingest_result()
Ingests a GenServer callback error event.
@spec ingest_genserver_callback_start( ElixirScope.Capture.RingBuffer.t(), atom(), pid(), term() ) :: ingest_result()
Ingests a GenServer callback start event.
@spec ingest_genserver_callback_success( ElixirScope.Capture.RingBuffer.t(), atom(), pid(), term() ) :: ingest_result()
Ingests a GenServer callback success event.
@spec ingest_liveview_assigns(ElixirScope.Capture.RingBuffer.t(), atom(), term()) :: ingest_result()
Ingests LiveView assigns change event.
@spec ingest_liveview_callback(ElixirScope.Capture.RingBuffer.t(), atom(), term()) :: ingest_result()
Ingests LiveView callback event.
@spec ingest_liveview_callback_error( ElixirScope.Capture.RingBuffer.t(), atom(), term(), atom(), term() ) :: ingest_result()
Ingests LiveView callback error event.
@spec ingest_liveview_callback_success( ElixirScope.Capture.RingBuffer.t(), atom(), term(), term() ) :: ingest_result()
Ingests LiveView callback success event.
@spec ingest_liveview_event( ElixirScope.Capture.RingBuffer.t(), binary(), map(), term() ) :: ingest_result()
Ingests LiveView event.
ingest_liveview_handle_event_complete(buffer, correlation_id, event, params, before_assigns, result)
@spec ingest_liveview_handle_event_complete( ElixirScope.Capture.RingBuffer.t(), term(), binary(), map(), map(), term() ) :: ingest_result()
Ingests a LiveView handle_event complete event.
@spec ingest_liveview_handle_event_start( ElixirScope.Capture.RingBuffer.t(), term(), binary(), map(), map() ) :: ingest_result()
Ingests a LiveView handle_event start event.
@spec ingest_liveview_mount_complete( ElixirScope.Capture.RingBuffer.t(), term(), module(), map() ) :: ingest_result()
Ingests a LiveView mount complete event.
@spec ingest_liveview_mount_start( ElixirScope.Capture.RingBuffer.t(), term(), module(), map(), map() ) :: ingest_result()
Ingests a LiveView mount start event.
@spec ingest_message_send(ElixirScope.Capture.RingBuffer.t(), pid(), pid(), term()) :: ingest_result()
Ingests a message send event.
@spec ingest_node_event(ElixirScope.Capture.RingBuffer.t(), atom(), atom(), map()) :: ingest_result()
Ingests a node event.
@spec ingest_partition_detected(ElixirScope.Capture.RingBuffer.t(), [atom()], map()) :: ingest_result()
Ingests a partition detected event.
@spec ingest_performance_metric( ElixirScope.Capture.RingBuffer.t(), atom(), number(), map() ) :: ingest_result()
Ingests a performance metric event.
@spec ingest_phoenix_action_complete( ElixirScope.Capture.RingBuffer.t(), atom(), term() ) :: ingest_result()
Ingests Phoenix action complete event.
@spec ingest_phoenix_action_error( ElixirScope.Capture.RingBuffer.t(), atom(), term(), atom(), term() ) :: ingest_result()
Ingests Phoenix action error event.
@spec ingest_phoenix_action_params( ElixirScope.Capture.RingBuffer.t(), atom(), term(), map() ) :: ingest_result()
Ingests Phoenix action parameters.
@spec ingest_phoenix_action_start(ElixirScope.Capture.RingBuffer.t(), atom(), term()) :: ingest_result()
Ingests Phoenix action start event.
@spec ingest_phoenix_action_success( ElixirScope.Capture.RingBuffer.t(), atom(), term(), term() ) :: ingest_result()
Ingests Phoenix action success event.
@spec ingest_phoenix_channel_join_complete( ElixirScope.Capture.RingBuffer.t(), term(), binary(), map(), term() ) :: ingest_result()
Ingests a Phoenix channel join complete event.
@spec ingest_phoenix_channel_join_start( ElixirScope.Capture.RingBuffer.t(), term(), binary(), map(), term() ) :: ingest_result()
Ingests a Phoenix channel join start event.
@spec ingest_phoenix_channel_message_complete( ElixirScope.Capture.RingBuffer.t(), term(), binary(), map(), term() ) :: ingest_result()
Ingests a Phoenix channel message complete event.
@spec ingest_phoenix_channel_message_start( ElixirScope.Capture.RingBuffer.t(), term(), binary(), map(), term() ) :: ingest_result()
Ingests a Phoenix channel message start event.
@spec ingest_phoenix_controller_entry( ElixirScope.Capture.RingBuffer.t(), term(), module(), atom(), map() ) :: ingest_result()
Ingests a Phoenix controller entry event.
@spec ingest_phoenix_controller_exit( ElixirScope.Capture.RingBuffer.t(), term(), module(), atom(), term() ) :: ingest_result()
Ingests a Phoenix controller exit event.
@spec ingest_phoenix_request_complete( ElixirScope.Capture.RingBuffer.t(), term(), integer(), binary(), number() ) :: ingest_result()
Ingests a Phoenix request complete event.
@spec ingest_phoenix_request_start( ElixirScope.Capture.RingBuffer.t(), term(), binary(), binary(), map(), binary() ) :: ingest_result()
Ingests a Phoenix request start event.
@spec ingest_process_spawn(ElixirScope.Capture.RingBuffer.t(), pid(), pid()) :: ingest_result()
Ingests a process spawn event.
@spec ingest_state_change(ElixirScope.Capture.RingBuffer.t(), pid(), term(), term()) :: ingest_result()
Ingests a state change event.
@spec set_buffer(ElixirScope.Capture.RingBuffer.t()) :: :ok
Sets the current buffer for runtime components.
This should be called during ElixirScope initialization.
@spec validate_performance(ElixirScope.Capture.RingBuffer.t()) :: :ok | {:error, term()}
Validates that ingestion performance meets targets.
Returns :ok
if performance is acceptable, {:error, reason}
otherwise.