This release changes retry behaviour and adds two request headers. Please read the upgrade note before upgrading.
Upgrade note: new request headers
This release sends two request headers that earlier versions did not:
Authorization (HTTP Basic, carrying your write key) and X-Retry-Count
(sent on retries only). If traffic to Segment passes through a proxy, gateway
or WAF that allowlists request headers, add both before upgrading or uploads
will be rejected.
Retry handling
- Uploads are retried on 408, 410, 429, 460, and 5xx except 501 and 505. 511 is retried only when an
oauth_manageris configured, and dropped otherwise. - A
Retry-Afterheader is honoured on any retryable response, not only 429. Numeric seconds and the RFC 7231 HTTP-date formats are both accepted, and the value is capped at 300 seconds. - Responses carrying
Retry-Afterare retried for up tomax_rate_limit_durationand do not consume the retry count. ARetry-Afterthat will not fit in what is left of the budget ends the episode rather than being shortened: retrying inside the window the server asked for sends a request it has already declined to serve, and the budget would be spent by then anyway. Other failures use exponential backoff from 500ms to a 60 second ceiling, limited bymax_retriesand bymax_total_backoff_durationas an upper bound. - New client options, both in seconds:
max_rate_limit_duration(default 1800) andmax_total_backoff_duration(default 43200). flush()andshutdown()are bounded by the same limits, and a pending retry does not delay shutdown.
Other changes
- The write key is sent as an
Authorization: Basicheader. It remains in the request body, so no server-side change is required. Deployments using OAuth continue to sendAuthorization: Bearer. X-Retry-Countis sent on retries, allowing the server to distinguish a retry from a first attempt. It is omitted on the first attempt.- Only 2xx responses count as a successful upload. A 3xx is reported as a failed upload rather than treated as delivered, and is not retried. The Segment endpoint does not redirect, so this affects only custom
hostvalues.
Full Changelog: 2.3.6...2.4.0