Skip to content

feat(rust-provider): add HTTP retry for flagLog writes - #452

Open
nicklasl wants to merge 1 commit into
mainfrom
nicklasl/rust-flaglog-retry
Open

feat(rust-provider): add HTTP retry for flagLog writes#452
nicklasl wants to merge 1 commit into
mainfrom
nicklasl/rust-flaglog-retry

Conversation

@nicklasl

Copy link
Copy Markdown
Member

Summary

  • Add retry with exponential backoff to LogSender::send() in the Rust provider, matching the JS provider's flagLog retry behavior
  • 3 attempts, 500ms base delay, 2x backoff, ±10% jitter
  • Retries on 5xx, 408, 429, and network errors; no retry on other 4xx
  • Respects Retry-After header from server (takes precedence over computed backoff)
  • Warns (not errors) after retries exhausted since log failures shouldn't disrupt flag evaluation

Test plan

  • Unit tests for retry on 503, 429, 408
  • Unit tests for no-retry on 400, 403
  • Unit test for Retry-After header respect
  • Unit tests for jitter bounds and parse_retry_after
  • is_retryable_status coverage for all relevant codes
  • Full crate test suite passes (95 tests)
  • clippy clean

🤖 Generated with Claude Code

nicklasl added a commit that referenced this pull request Aug 21, 2026
- Add retry with exponential backoff to flag log sending
- 3 attempts, 500ms base delay, 2x backoff, ±10% jitter
- Retries on 5xx, 408, 429, and network errors; no retry on 4xx
- Respects Retry-After header from server
- Warns (not errors) after retries exhausted
- Applies to both Edge and Cloudflare destinations
- Adds comprehensive test coverage with wiremock

Ported from PR #452 onto current main architecture which uses
LogDestination (Edge/Cloudflare) with fallback support.
@nicklasl
nicklasl force-pushed the nicklasl/rust-flaglog-retry branch from 8047e92 to 4c55c9e Compare August 21, 2026 13:31
@nicklasl
nicklasl marked this pull request as ready for review August 21, 2026 13:31
@nicklasl

Copy link
Copy Markdown
Member Author

PR Updated ✅

Rebased onto current main (a866c61) and ported the retry logic to work with the new architecture.

Changes from original PR

The original PR was based on an older version of logger.rs. Since then, main added:

  • Multi-destination support (Edge + Cloudflare)
  • Fallback logic between destinations
  • Per-destination encoding (protobuf vs ingest format)

What was done

✅ Ported retry-with-backoff logic onto the current architecture
✅ Retry now applies to both Edge and Cloudflare destinations
✅ Preserves fallback semantics (after retries exhausted on primary, fallback is still attempted)
✅ All tests passing (13 logger tests including 9 new retry tests)
✅ Clippy clean
✅ Now MERGEABLE (was CONFLICTING)

Test Results

test logger::tests::test_apply_jitter_within_bounds ... ok
test logger::tests::test_encode_ingest_request_empty_account_id ... ok
test logger::tests::test_encode_ingest_request_empty_batch ... ok
test logger::tests::test_encode_ingest_request_roundtrip ... ok
test logger::tests::test_is_retryable_status ... ok
test logger::tests::test_parse_retry_after ... ok
test logger::tests::no_retry_on_403 ... ok
test logger::tests::no_retry_on_client_error ... ok
test logger::tests::retries_on_429_and_succeeds ... ok
test logger::tests::retries_on_503_up_to_max_attempts ... ok
test logger::tests::retries_on_network_error ... ok
test logger::tests::respects_retry_after_header ... ok
test logger::tests::send_succeeds_on_first_attempt ... ok

test result: ok. 13 passed; 0 failed

Ready for review! 🚀

@nicklasl
nicklasl requested a review from vahidlazio August 21, 2026 14:44
- Add retry with exponential backoff to flag log sending
- 3 attempts, 500ms base delay, 2x backoff, ±10% jitter
- Retries on 5xx, 408, 429, and network errors; no retry on 4xx
- Respects Retry-After header from server
- Warns (not errors) after retries exhausted
- Applies to both Edge and Cloudflare destinations
- Adds comprehensive test coverage with wiremock

Ported from PR #452 onto current main architecture which uses
LogDestination (Edge/Cloudflare) with fallback support.
@nicklasl
nicklasl force-pushed the nicklasl/rust-flaglog-retry branch from 4c55c9e to 4b5342d Compare August 21, 2026 14:47
@nicklasl

Copy link
Copy Markdown
Member Author

Fixed 🔧

Sorry about that! My first push accidentally uploaded file references instead of actual file contents (used @filename incorrectly with the API).

New commit: 4b5342d

Files are now correct:

  • ✅ logger.rs: 17,919 bytes (was broken at 40 bytes)
  • ✅ Cargo.toml: correct content
  • ✅ README.md: correct content
  • ✅ Cargo.lock: correct content

CI should pass now! 🤞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant