Skip to content

feat: State change notification for flags client (for OpenFeature)#3042

Merged
typotter merged 1 commit into
feature/flags-ofeatfrom
typo/openfeature-flags-client-state
Dec 9, 2025
Merged

feat: State change notification for flags client (for OpenFeature)#3042
typotter merged 1 commit into
feature/flags-ofeatfrom
typo/openfeature-flags-client-state

Conversation

@typotter

@typotter typotter commented Dec 8, 2025

Copy link
Copy Markdown
Contributor

Summary

This PR cherry-picks the state management implementation from PR #3025 onto the feature/flags-ofeat branch.

This intermediate PR enables PR #2998 (OpenFeature provider) to depend on state management functionality without polluting its diff with unrelated state management commits.

What's Included

State management infrastructure for FlagsClient:

  • FlagsClientState sealed class (NotReady, Ready, Reconciling, Stale, Error)
  • StateObservable interface (getCurrentState, addListener, removeListener)
  • FlagsStateManager internal implementation
  • FlagsStateListener callback interface
  • Separate executors for network vs state notifications

Dependencies

None - this is a clean cherry-pick of merged state management work.

Review Strategy

This is a dependency branch for stacked PRs:

  1. This PR: State management on feature/flags-ofeat
  2. PR feat: Openfeature Provider implementation powered by DD Flags #2998: OpenFeature provider based on this PR

Review notes:

🤖 Generated with Claude Code

Implements state observation API for FlagsClient:
- Add FlagsClientState sealed class (NotReady, Reconciling, Ready, Stale, Error)
- Add FlagsStateListener interface for state change callbacks
- Add StateObservable interface bundling getCurrentState, addListener, removeListener, and Flow
- Implement FlagsStateManager with ExecutorService for ordered state notifications
- Add synchronized blocks for defensive thread safety
- Expose state via client.state property
- Add StateFlow support for Kotlin coroutines
- Ensure Java compatibility
- Update NoOpFlagsClient with Ready state
- Add comprehensive tests

PR #3025
@typotter
typotter marked this pull request as ready for review December 8, 2025 16:46
@typotter
typotter requested a review from a team as a code owner December 8, 2025 16:46
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Dec 8, 2025

Copy link
Copy Markdown

🎯 Code Coverage
Patch Coverage: 77.27%
Total Coverage: 71.26% (+0.01%)

View detailed report

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: d6a97bf | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@codecov-commenter

codecov-commenter commented Dec 8, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 67.18750% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.30%. Comparing base (6c2f8ab) to head (d6a97bf).
⚠️ Report is 550 commits behind head on feature/flags-ofeat.

Files with missing lines Patch % Lines
...in/kotlin/com/datadog/android/flags/FlagsClient.kt 0.00% 13 Missing ⚠️
...atadog/android/flags/internal/FlagsStateManager.kt 86.36% 3 Missing ⚠️
.../datadog/android/flags/internal/NoOpFlagsClient.kt 50.00% 2 Missing ⚠️
...id/flags/internal/evaluation/EvaluationsManager.kt 93.33% 1 Missing ⚠️
...lags/internal/repository/DefaultFlagsRepository.kt 0.00% 0 Missing and 1 partial ⚠️
...om/datadog/android/flags/model/FlagsClientState.kt 83.33% 1 Missing ⚠️
Additional details and impacted files
@@                   Coverage Diff                   @@
##           feature/flags-ofeat    #3042      +/-   ##
=======================================================
+ Coverage                71.10%   71.30%   +0.19%     
=======================================================
  Files                      860      862       +2     
  Lines                    31311    31365      +54     
  Branches                  5275     5277       +2     
=======================================================
+ Hits                     22263    22362      +99     
+ Misses                    7556     7521      -35     
+ Partials                  1492     1482      -10     
Files with missing lines Coverage Δ
...tadog/android/flags/internal/DatadogFlagsClient.kt 91.30% <100.00%> (+1.60%) ⬆️
...id/flags/internal/evaluation/EvaluationsManager.kt 91.18% <93.33%> (+1.89%) ⬆️
...lags/internal/repository/DefaultFlagsRepository.kt 64.00% <0.00%> (-1.31%) ⬇️
...om/datadog/android/flags/model/FlagsClientState.kt 83.33% <83.33%> (ø)
.../datadog/android/flags/internal/NoOpFlagsClient.kt 93.10% <50.00%> (-6.90%) ⬇️
...atadog/android/flags/internal/FlagsStateManager.kt 86.36% <86.36%> (ø)
...in/kotlin/com/datadog/android/flags/FlagsClient.kt 35.59% <0.00%> (-2.59%) ⬇️

... and 42 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@0xnm 0xnm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not quite sure about the need of cherry-picking.

What we usually do is simply keeping feature branches up-to-date with develop branch by merging develop branch into the feature branch, so I guess we could do this instead.

But this approach is not blocking to me.

@typotter

typotter commented Dec 9, 2025

Copy link
Copy Markdown
Contributor Author

Thanks Nikita.

@typotter
typotter merged commit d065edf into feature/flags-ofeat Dec 9, 2025
27 of 28 checks passed
@typotter
typotter deleted the typo/openfeature-flags-client-state branch December 9, 2025 15:16
@ncreated
ncreated restored the typo/openfeature-flags-client-state branch April 9, 2026 10:18
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