# `Tinkex.Telemetry.Reporter.Backoff`
[🔗](https://github.com/North-Shore-AI/tinkex/blob/v0.4.0/lib/tinkex/telemetry/reporter/backoff.ex#L1)

Retry and backoff calculation logic for telemetry reporter.

Implements exponential backoff with jitter for failed telemetry sends.

# `calculate_backoff_delay`

```elixir
@spec calculate_backoff_delay(non_neg_integer(), pos_integer()) :: pos_integer()
```

Calculate exponential backoff delay with jitter.

Formula: `base_delay * 2^attempt + jitter`

Where jitter is a random value up to 10% of the base delay.

Examples:
  * attempt 0, base 1000ms -> 1000ms + (0-100ms jitter) = 1000-1100ms
  * attempt 1, base 1000ms -> 2000ms + (0-200ms jitter) = 2000-2200ms
  * attempt 2, base 1000ms -> 4000ms + (0-400ms jitter) = 4000-4400ms

# `send_batch_with_retry`

```elixir
@spec send_batch_with_retry(map(), map(), :sync | :async, non_neg_integer()) ::
  :ok | :error
```

Send a batch of events with retry logic and exponential backoff.

Attempts to send the request up to `max_retries` times. On failure,
waits with exponential backoff before retrying.

Parameters:
  * `request` - the telemetry request map
  * `state` - the reporter state (contains config, timeouts, retry settings)
  * `mode` - `:sync` or `:async` send mode
  * `attempt` - current attempt number (0-indexed, defaults to 0)

Returns `:ok` on success, `:error` after all retries exhausted.

---

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