Skip to content

feat: add logging hook#577

Open
danjuv wants to merge 5 commits intoopen-feature:mainfrom
danjuv:feat/logging-hook
Open

feat: add logging hook#577
danjuv wants to merge 5 commits intoopen-feature:mainfrom
danjuv:feat/logging-hook

Conversation

@danjuv
Copy link

@danjuv danjuv commented Mar 14, 2026

This PR

  • Adds a LoggingHook as per spec
  • Refactors the hook package to split core hook classes into a separate file to avoid circular imports and separate the LoggingHook from core hook functionality

Related Issues

Fixes #570

Notes

  • I ultimately decided split init because the LoggingHook was a utility and felt it made sense to reflect that in code. But it does make this PR a little more complex. I'm happy to revert the refactor and bundle everything into init.py if anyone has any preference

@danjuv danjuv requested review from a team as code owners March 14, 2026 15:14
@gemini-code-assist
Copy link

Summary of Changes

Hello, 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 introduces a new LoggingHook to the OpenFeature Python SDK, enhancing observability during flag evaluation. It also includes a structural refactoring of the hook package to better organize core hook functionalities and accommodate the new logging hook, ensuring a cleaner and more maintainable codebase.

Highlights

  • New LoggingHook: Implemented a LoggingHook as per the OpenFeature specification, providing detailed logging during flag evaluation for debugging and troubleshooting.
  • Hook Package Refactoring: Refactored the hook package by moving core hook classes into a dedicated hook.py file to improve modularity and prevent circular imports.
Changelog
  • README.md
    • Added a new section detailing the LoggingHook and its usage.
  • openfeature/hook/init.py
    • Removed core Hook class definitions and related types.
    • Updated imports to reference Hook and related types from openfeature.hook.hook.
    • Added import for LoggingHook from openfeature.hook.logging_hook.
    • Updated __all__ to include LoggingHook.
  • openfeature/hook/hook.py
    • Created a new file containing the Hook class, HookContext, HookData, HookHints, and HookType definitions.
  • openfeature/hook/logging_hook.py
    • Created a new file implementing the LoggingHook class, which logs flag evaluation details at before, after, and error stages.
    • Included options to include evaluation context in logs.
  • tests/hook/test_logging_hook.py
    • Added a new test file with unit tests for the LoggingHook, verifying its logging behavior for different stages and configurations.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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

  1. 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.

@danjuv danjuv changed the title Feat/logging hook feat: add logging hook Mar 14, 2026
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 a LoggingHook for enhanced debugging and refactors the hook package structure to prevent circular dependencies. The implementation is solid, and the addition of tests is great. I've included a few suggestions to improve performance and code consistency.

danjuv added 3 commits March 15, 2026 02:16
Signed-off-by: Danju Visvanathan <danju.visvanathan@gmail.com>
Signed-off-by: Danju Visvanathan <danju.visvanathan@gmail.com>
Signed-off-by: Danju Visvanathan <danju.visvanathan@gmail.com>
@danjuv danjuv force-pushed the feat/logging-hook branch from 72c1a9d to 2b7f68c Compare March 14, 2026 15:16
danjuv added 2 commits March 15, 2026 02:19
Signed-off-by: Danju Visvanathan <danju.visvanathan@gmail.com>
Signed-off-by: Danju Visvanathan <danju.visvanathan@gmail.com>
@codecov
Copy link

codecov bot commented Mar 14, 2026

Codecov Report

❌ Patch coverage is 98.49624% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.31%. Comparing base (a6366e2) to head (dafe7b6).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
openfeature/hook/hook.py 94.87% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #577      +/-   ##
==========================================
+ Coverage   98.18%   98.31%   +0.13%     
==========================================
  Files          41       44       +3     
  Lines        1982     2076      +94     
==========================================
+ Hits         1946     2041      +95     
+ Misses         36       35       -1     
Flag Coverage Δ
unittests 98.31% <98.49%> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

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.

Implement LoggingHook

2 participants