Overview
The SDK includes built-in retry logic with exponential backoff. When a network request fails, it automatically retries with increasing delays, improving reliability in unstable network conditions.Default Behavior
By default, the SDK:- Retries up to 3 times on failure
- Uses 1000ms base backoff delay
- Doubles the delay after each retry (exponential backoff)
Configuration
Customize retry behavior per trace:Options
| Option | Type | Default | Description |
|---|---|---|---|
maxRetries | number | 3 | Maximum retry attempts |
retryBackoff | number | 1000 | Base delay in milliseconds |
Exponential Backoff
The delay doubles after each failed attempt:| Attempt | Delay (default) | Delay (2000ms base) |
|---|---|---|
| 1 | 0ms (immediate) | 0ms |
| 2 | 1000ms | 2000ms |
| 3 | 2000ms | 4000ms |
| 4 | 4000ms | 8000ms |
| 5 | 8000ms | 16000ms |
Use Cases
Critical Operations
For important data that must be delivered:Low-Priority Logging
For non-critical data where you want to fail fast:Disable Retries
SetmaxRetries: 0 to disable retry logic:
Error Handling
The SDK handles retries silently - your code doesn’t need to manage failures. However, if all retries are exhausted, the data is lost. For critical operations, consider:- Using more retries
- Implementing application-level backup
- Monitoring for systematic failures
Network Conditions
The retry logic is especially useful for:- Mobile networks - Intermittent connectivity
- Slow connections - Request timeouts
- Server issues - Temporary 5xx errors
- Rate limiting - Brief throttling periods
Best Practices
Match Retries to Importance
Consider Total Time
With exponential backoff, retries can take significant time:| maxRetries | retryBackoff | Max Total Time |
|---|---|---|
| 3 | 1000ms | ~7 seconds |
| 5 | 1000ms | ~31 seconds |
| 5 | 2000ms | ~62 seconds |
Don’t Over-Retry
Excessive retries can:- Block the flush queue
- Delay subsequent traces
- Waste bandwidth on permanent failures