Tinkex.Telemetry.Reporter.Backoff (Tinkex v0.3.4)
View SourceRetry and backoff calculation logic for telemetry reporter.
Implements exponential backoff with jitter for failed telemetry sends.
Summary
Functions
Calculate exponential backoff delay with jitter.
Send a batch of events with retry logic and exponential backoff.
Functions
@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
@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 mapstate- the reporter state (contains config, timeouts, retry settings)mode-:syncor:asyncsend modeattempt- current attempt number (0-indexed, defaults to 0)
Returns :ok on success, :error after all retries exhausted.