-
Couldn't load subscription status.
- Fork 11
feat(log): Improve error log in OpenFeatureClient #156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @jaugustin, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request refines the error handling and logging within the OpenFeature client. The primary goal is to make error messages more structured and informative, aligning with standard logging practices, and to provide richer context for debugging issues that arise during feature flag evaluation.
Highlights
- Improved Error Logging: The error log message format in
OpenFeatureClienthas been updated to follow PSR-3 best practices, using placeholders for dynamic values. - Enhanced Debugging Context: The full
Exceptionobject is now included in the log context when an error occurs during feature flag evaluation, providing more comprehensive debugging information. - Unit Test Updates: Corresponding unit tests for
OpenFeatureClienthave been modified to assert the new log message format and the presence of theExceptionobject in the log context.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this 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 improves error logging in OpenFeatureClient by adopting PSR-3 best practices, including using placeholders and adding the full exception object to the log context. This is a valuable change for debugging. The corresponding unit test has been updated to reflect these changes. I've added one suggestion to further improve the test's maintainability by providing more specific failure messages.
tests/unit/OpenFeatureClientTest.php
Outdated
| Mockery::on(fn ($context) => isset($context['flagKey'], $context['errorMessage'], $context['exception']) && | ||
| $context['flagKey'] === 'flagKey' && | ||
| $context['errorMessage'] === 'NETWORK_ERROR' && | ||
| $context['exception'] instanceof Exception && | ||
| $context['exception']->getMessage() === 'NETWORK_ERROR'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For better test failure diagnostics, consider using Mockery::with() along with PHPUnit assertions instead of Mockery::on(). When Mockery::on()'s closure returns false, the test failure message is generic. By using Mockery::with() and assertions, you get specific feedback on which assertion failed, making it easier to debug. This improves the maintainability of the test.
Mockery::with(function ($context) {
$this->assertIsArray($context);
$this->assertArrayHasKey('flagKey', $context);
$this->assertSame('flagKey', $context['flagKey']);
$this->assertArrayHasKey('errorMessage', $context);
$this->assertSame('NETWORK_ERROR', $context['errorMessage']);
$this->assertArrayHasKey('exception', $context);
$this->assertInstanceOf(Exception::class, $context['exception']);
$this->assertSame('NETWORK_ERROR', $context['exception']->getMessage());
return true;
}),c523b5a to
b8d6da9
Compare
|
Thank you for the PR @jaugustin 👋 I will have time to review, approve, and merge later this evening if all looks good. For now I have approved the CI run for you. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #156 +/- ##
============================================
+ Coverage 95.19% 96.41% +1.21%
Complexity 227 227
============================================
Files 40 40
Lines 583 585 +2
============================================
+ Hits 555 564 +9
+ Misses 28 21 -7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Change log message to follow best practice of PSR3, Log Exception object to help debuging, when provider throw Exception Signed-off-by: jaugustin <564420+jaugustin@users.noreply.github.com>
Signed-off-by: jaugustin <564420+jaugustin@users.noreply.github.com>
28559d2 to
913d407
Compare
🤖 I have created a release *beep* *boop* --- ## [2.1.0](2.0.12...2.1.0) (2025-09-14) ### ✨ New Features * **log:** Improve error log in OpenFeatureClient ([#156](#156)) ([d28d9c3](d28d9c3)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Change log message to follow best practice of PSR3, Log Exception object to help debuging, when provider throw Exception
This PR
Related Issues
Notes
Follow-up Tasks
How to test