ScoutApm.Error.ErrorService (scout_apm v2.0.0)

Copy Markdown

Background GenServer that batches and sends errors to Scout APM's error endpoint.

Implements a queue with batching (default 5 errors per batch) and a maximum queue size (default 500) to prevent memory issues.

Summary

Functions

Returns a specification to start this module under a supervisor.

Waits for the queue to drain. Used in tests and shutdown.

Forces an immediate flush of queued errors. Used in tests.

Sends an error to the service for batched delivery. Non-blocking - returns immediately.

Types

t()

@type t() :: %ScoutApm.Error.ErrorService{
  queue: :queue.queue(ScoutApm.Error.ErrorData.t()),
  queue_size: non_neg_integer(),
  timer_ref: reference() | nil
}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

drain(timeout \\ 5000)

@spec drain(timeout :: non_neg_integer()) :: :ok | :timeout

Waits for the queue to drain. Used in tests and shutdown.

flush()

@spec flush() :: :ok

Forces an immediate flush of queued errors. Used in tests.

send(error)

@spec send(ScoutApm.Error.ErrorData.t()) :: :ok

Sends an error to the service for batched delivery. Non-blocking - returns immediately.

start_link(opts \\ [])