-
Notifications
You must be signed in to change notification settings - Fork 37
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
feat: Add hook-data concept for hooks. #273
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Ryan Lamb <[email protected]>
c42ef76
to
d391718
Compare
Signed-off-by: Ryan Lamb <[email protected]>
cb5cabb
to
2110b92
Compare
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.
I like this proposal, but I would like to see how it could be implemented in an SDK. Properly scoping hook data may be complicated.
Co-authored-by: Michael Beemer <[email protected]> Signed-off-by: Ryan Lamb <[email protected]>
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.
I definitely support this idea. I left a few comments. My biggest question is how we can define this so it's non-breaking for existing hooks.
Signed-off-by: Ryan Lamb <[email protected]>
c84eebd
to
29bc48c
Compare
Signed-off-by: Ryan Lamb <[email protected]>
Signed-off-by: Ryan Lamb <[email protected]>
Signed-off-by: Ryan Lamb <[email protected]>
Signed-off-by: Ryan Lamb <[email protected]>
I should be able to find time to update a OF SDK to demonstrate, but it may take me a bit. It will be a little different now that we added it to hook context, but you can see what we did in the LD SDKs as its own argument: In our case we create the data when we call the hook, and the return is the new data. Which means we can just map it to an array. But, if that was not the case, as it will be in the OF example you instead do this.
Some pseudocode:
The hooks are stable for a specific invocation of stages, so you just need an equal sized list of hook data. |
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.
I like the change and as far as I can see, adding the hook data does not break the old hooks when it is implemented.
Co-authored-by: Lukas Reining <[email protected]> Signed-off-by: Ryan Lamb <[email protected]>
Signed-off-by: Ryan Lamb <[email protected]>
Signed-off-by: Ryan Lamb <[email protected]>
I think this was resolved via the pseudocode. |
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.
Not that my approval changes anything, but this proposal looks really promising.
This PR
Add support for the hook-data concept for hooks. Hook-data allows for per-evaluation data to be propagated between hooks.
This is especially useful for analytics purposes where you may want to measure things that happen between stages, or you want to do something like create a span in one stage and close it in another.
This concept is similar to the
series data
concept for LaunchDarkly hooks. https://github.com/launchdarkly/open-sdk-specs/tree/main/specs/HOOK-hooks#evaluationseriesdataUnlike
series data
the data in this approach is mutable. This is because thebefore
stage already has a return value. We could workaround this by specifying a return structure, but it maybe seems more complex. The data is only passed to a specific hook instance, so mutability is not of great concern.Some functional languages may still need to use an immutable with return values approach.
I can create an OFEP if we think this merits discussion prior to proposal.
Related Issues
Related discussion in a PR comment.
open-feature/java-sdk#1049 (comment)