instrument_otlp_retry (instrument v1.0.0)
View SourceRetry helper for OTLP exporters.
Classifies HTTP / network errors as retryable or permanent per the OpenTelemetry specification and implements bounded exponential backoff with optional Retry-After header support.
Summary
Functions
Classifies an HTTP / hackney error as retryable or permanent. Retryable: 408, 429, and 5xx except 501; transient transport failures (timeout, closed, econnrefused, nxdomain, ehostunreach, enetunreach). Everything else is permanent.
Equivalent to send_with_retry(Method, Url, Headers, Body, Options, #{}).
Sends an HTTP request with bounded exponential backoff. On a retryable error, waits min(InitialDelay * 2^Attempt, MaxDelay) and retries up to MaxRetries additional times (so MaxRetries + 1 total attempts). If the response carries a Retry-After header (seconds or HTTP-date) the value is clamped to [0, MaxDelay] and used as the next delay.
Types
Functions
-spec classify_error(term()) -> retryable | permanent.
Classifies an HTTP / hackney error as retryable or permanent. Retryable: 408, 429, and 5xx except 501; transient transport failures (timeout, closed, econnrefused, nxdomain, ehostunreach, enetunreach). Everything else is permanent.
Equivalent to send_with_retry(Method, Url, Headers, Body, Options, #{}).
-spec send_with_retry(atom(), binary(), list(), iodata(), list(), #{max_retries => non_neg_integer(), initial_delay_ms => pos_integer(), max_delay_ms => pos_integer()}) -> http_result().
Sends an HTTP request with bounded exponential backoff. On a retryable error, waits min(InitialDelay * 2^Attempt, MaxDelay) and retries up to MaxRetries additional times (so MaxRetries + 1 total attempts). If the response carries a Retry-After header (seconds or HTTP-date) the value is clamped to [0, MaxDelay] and used as the next delay.