Skip to content

Conversation

@askpt
Copy link
Member

@askpt askpt commented Oct 3, 2025

This PR

This pull request introduces support for provider hooks in the Multi-Provider feature, ensuring that each provider's hooks are executed with context isolation as per the OpenFeature specification. It also updates the documentation to reflect these changes and refines how evaluation contexts and logging are handled in provider evaluations.

Enhancements to Multi-Provider hook support:

  • Added execution of provider hooks for each underlying provider in Multi-Provider, with context isolation so that modifications by one provider's hooks do not affect others. This is implemented in ProviderExtensions.cs and integrated into the evaluation logic in MultiProvider.cs. [1] [2] [3] [4]
  • Introduced helper methods ExecuteBeforeEvaluationHooksAsync and ExecuteAfterEvaluationHooksAsync in ProviderExtensions.cs to manage hook execution and error handling for each provider.

Documentation updates:

  • Updated the README.md to clarify that provider hooks are now supported in Multi-Provider, and events are not fully supported. The limitations section was revised to remove the statement that hooks are not supported. [1] [2]

Internal improvements:

  • Updated method signatures and usages in ProviderExtensions.cs and MultiProvider.cs to pass a logger instance for better diagnostics and error logging during hook execution. [1] [2] [3]
  • Added necessary using directives to support new functionality, such as System.Collections.Immutable and Microsoft.Extensions.Logging. [1] [2]

Related Issues

Fixes #551

@askpt askpt linked an issue Oct 3, 2025 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Oct 3, 2025

Codecov Report

❌ Patch coverage is 92.30769% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.76%. Comparing base (51aefbc) to head (e9d7f0c).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ture.Providers.MultiProvider/ProviderExtensions.cs 92.13% 0 Missing and 7 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #594      +/-   ##
==========================================
+ Coverage   89.52%   89.76%   +0.23%     
==========================================
  Files          77       77              
  Lines        3084     3166      +82     
  Branches      350      364      +14     
==========================================
+ Hits         2761     2842      +81     
+ Misses        256      253       -3     
- Partials       67       71       +4     

☔ 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 askpt force-pushed the askpt/551-feature-implement-hooks-in-multi-provider branch from 651693a to 1d400ac Compare October 7, 2025 20:21
@askpt askpt requested a review from Copilot October 7, 2025 20:37
Copy link
Contributor

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 enhances the Multi-Provider feature in the OpenFeature .NET SDK by implementing support for provider hooks with context isolation and improving the overall hook execution mechanism.

  • Added hook execution support for individual providers within the Multi-Provider
  • Implemented context isolation between providers to prevent hook modifications from affecting other providers
  • Updated evaluation logic to pass logger instance and use modified contexts from hooks

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/OpenFeature.Providers.MultiProvider/ProviderExtensions.cs Added comprehensive hook execution logic with before/after/error/finally hook support and context isolation
src/OpenFeature.Providers.MultiProvider/MultiProvider.cs Added GetProviderHooks method and updated evaluation calls to include logger parameter
test/OpenFeature.Providers.MultiProvider.Tests/ProviderExtensionsTests.cs Updated test calls to include logger parameter and added new tests for hook execution
test/OpenFeature.Providers.MultiProvider.Tests/MultiProviderTests.cs Added comprehensive hook testing including context isolation and error handling scenarios
README.md Updated documentation to reflect hook support and removed hook limitations

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

@askpt askpt marked this pull request as ready for review October 7, 2025 20:39
@askpt askpt requested a review from a team as a code owner October 7, 2025 20:39
@askpt askpt marked this pull request as draft October 8, 2025 08:05
@askpt
Copy link
Member Author

askpt commented Oct 8, 2025

Put this PR in draft. Testing a couple of cases which seems to do double hook execution instead of a single one.

@askpt askpt marked this pull request as ready for review October 8, 2025 16:57
@askpt askpt requested a review from Copilot October 8, 2025 16:57
Copy link
Contributor

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


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

This was referenced Dec 19, 2025
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 Hooks in Multi-Provider

5 participants