# `ScoutApm.Error.ErrorService`

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.

# `t`

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

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `drain`

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

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

# `flush`

```elixir
@spec flush() :: :ok
```

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

# `send`

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

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

# `start_link`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
