Skip to content

Conversation

askpt
Copy link
Member

@askpt askpt commented Aug 26, 2025

This PR

This pull request introduces event handling and status management improvements to the MultiProvider class in the OpenFeature.Providers.MultiProvider package. The main changes include adding infrastructure to listen to events from underlying providers, emitting events based on provider and aggregate status changes, and ensuring proper shutdown of event processing. These enhancements improve observability and reliability of the multi-provider setup.

Event Handling Infrastructure

  • Added event listening infrastructure to MultiProvider, including a dictionary to track event listening tasks and a cancellation token source for clean shutdown. Event listeners are started for all registered providers during initialization. [1] [2] [3]

Event Emission and Status Management

  • Implemented logic to emit error and ready events during initialization and evaluation, improving visibility into provider failures and readiness. [1] [2]
  • Added logic to handle provider events, update individual provider statuses, and emit aggregate status change events for MultiProvider. Includes special handling for configuration change events.

Shutdown and Disposal

  • Ensured proper shutdown of event processing by cancelling event listeners and waiting for event tasks to complete during disposal.

Project Configuration

  • Updated OpenFeature.csproj to add InternalsVisibleTo for OpenFeature.Providers.MultiProvider, allowing internal access for testing and integration.

Related Issues

Fixes #552

Notes

  • I cannot get the coverage up to the requirements since there are some very edge cases that I cannot easily unit test. The proposed coverage is already good which covers most of the current implementation for events.

askpt added 9 commits August 26, 2025 17:02
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
…nagement

Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
…vider

Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
…n MultiProvider

Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
…r unsupported run modes

Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
… state handling

Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
@askpt askpt linked an issue Aug 26, 2025 that may be closed by this pull request
Copy link

codecov bot commented Aug 26, 2025

Codecov Report

❌ Patch coverage is 82.64840% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.52%. Comparing base (f43625c) to head (edd102a).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...enFeature.Providers.MultiProvider/MultiProvider.cs 82.64% 30 Missing and 8 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #568      +/-   ##
==========================================
- Coverage   90.07%   89.52%   -0.55%     
==========================================
  Files          77       77              
  Lines        2881     3084     +203     
  Branches      327      350      +23     
==========================================
+ Hits         2595     2761     +166     
- Misses        226      256      +30     
- Partials       60       67       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

askpt added 3 commits August 26, 2025 21:31
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
… error handling

Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
…sistency

Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces event handling to the MultiProvider, which is a significant and valuable feature. The implementation is well-structured and includes a comprehensive set of tests for the new functionality. I have identified a few areas for improvement to enhance robustness and performance:

  • A potentially risky use of Task.Run in the constructor should be addressed to prevent unobserved exceptions.
  • The event processing loop can be made more efficient.
  • A minor bug in a test helper method could lead to test timeouts.

Overall, this is a solid implementation of a complex feature. Addressing these points will further improve the quality of the code.

…mance and clarity

Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
@askpt askpt marked this pull request as ready for review August 26, 2025 21:14
@askpt askpt requested a review from a team as a code owner August 26, 2025 21:14
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
…utdown

Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
…provider

Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
@askpt askpt requested review from Copilot and kinyoklion September 11, 2025 16:30
Copy link
Contributor

@Copilot 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 PR adds event handling and status management capabilities to the MultiProvider class, enabling it to listen to events from underlying providers and emit appropriate events based on provider and aggregate status changes. The enhancement improves observability and provides specification-compliant event behavior for the multi-provider setup.

  • Added comprehensive event infrastructure including event listening, status tracking, and proper event emission
  • Implemented proper error handling during evaluation with event emission for unsupported run modes and general exceptions
  • Enhanced shutdown and disposal processes to properly clean up event processing resources

Reviewed Changes

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

Show a summary per file
File Description
TestProvider.cs New test utility class providing basic FeatureProvider implementation for testing event scenarios
MultiProviderEventTests.cs Comprehensive test suite covering event emission, status transitions, and error handling scenarios
MultiProviderTests.cs Updated test to handle error details return instead of exception throwing for unsupported run modes
OpenFeature.csproj Added internal visibility for MultiProvider package to access OpenFeature internals
README.md Added documentation section explaining event handling behavior and lifecycle
MultiProvider.cs Core implementation of event handling infrastructure, status management, and proper cleanup

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
@askpt askpt marked this pull request as ready for review September 11, 2025 16:38
@askpt askpt requested a review from chrfwow September 26, 2025 09:58
…ries

Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
…mplement-events-in-multi-provider' into askpt/552-feature-implement-events-in-multi-provider
…ore adding

Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
askpt added 2 commits October 2, 2025 09:20
@askpt askpt requested a review from arttonoyan October 2, 2025 10:05
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.

[FEATURE] Implement events in multi-provider

6 participants