Skip to content

Conversation

@junaed-optimizely
Copy link
Contributor

Summary

This pull request introduces a standardized retry and exponential backoff mechanism for event dispatching across the Optimizely SDKs. The changes ensure that failed event dispatches are retried up to three times with increasing delays, improving reliability in the face of transient network or server errors.

Test plan

Existing tests should pass

Issues

  • FSSDK-12148

Copy link

@muzahidul-opti muzahidul-opti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, made a couple of comments

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request introduces a standardized retry and exponential backoff mechanism for event dispatching across the Optimizely C# SDK. The changes implement automatic retries (up to 3 total attempts) with exponential backoff (starting at 200ms, doubling to max 1000ms) for failed event dispatches on 5xx server errors and network failures.

Changes:

  • Created EventRetryConfig class with centralized retry constants (max 2 retries, 200ms initial backoff, 1000ms max backoff, 2.0x multiplier)
  • Refactored WebRequestEventDispatcher35 and HttpClientEventDispatcher45 to implement retry logic with exponential backoff
  • Updated OdpEventManager to use the new EventRetryConfig constants and enhanced error logging
  • Removed MAX_RETRIES constant from ODP Constants class in favor of centralized configuration
  • Added comprehensive unit tests for HttpClientEventDispatcher45 covering success, retry, and backoff scenarios

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
OptimizelySDK/Event/EventRetryConfig.cs New configuration class defining retry constants (max retries, backoff timing)
OptimizelySDK/Event/Dispatcher/HttpClientEventDispatcher45.cs Refactored dispatcher with retry logic and exponential backoff for .NET 4.5+
OptimizelySDK/Event/Dispatcher/WebRequestEventDispatcher35.cs Refactored dispatcher with retry logic for .NET 3.5/4.0
OptimizelySDK/Odp/OdpEventManager.cs Updated to use EventRetryConfig constants and improved error logging
OptimizelySDK/Odp/Constants.cs Removed MAX_RETRIES constant (moved to EventRetryConfig)
OptimizelySDK.Tests/EventTests/HttpClientEventDispatcher45Test.cs New comprehensive test suite for retry behavior and backoff timing
OptimizelySDK.Tests/OdpTests/OdpEventManagerTests.cs Updated test timeout to accommodate backoff delays
Various .csproj files Added EventRetryConfig.cs to project configurations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@mikechu-optimizely mikechu-optimizely left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation looks good. Small suggestion below.

@junaed-optimizely junaed-optimizely merged commit 1c3cac4 into master Jan 21, 2026
9 of 10 checks passed
@junaed-optimizely junaed-optimizely deleted the junaed/fssdk-12148-event-retries-addition branch January 21, 2026 17:08
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.

4 participants