-
Notifications
You must be signed in to change notification settings - Fork 64
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
[FEATURE] Specify custom seed for fractional operator #1264
Comments
I took a stab at making this possible in flagd core -- see reference PRs above This would also require implementing same behavior in each language's in-memory provider which should be pretty straightforward. (And of course updating more docs 😃) Happy to proceed further if this proposal makes sense |
This sounds like a reasonable idea, and I appreciate your pr! I'll give it a proper look tomorrow. |
Hey @colebaileygit, this is great. We had discussions about this in the past and I actually thought it was already possible 😅. Our idea back in the day was basically the same as what you're proposing. If @toddbaert agrees, perhaps we start by updating flagd and the in-process implementations before updating the schema and docs. |
I think you've highlighted a legitimate use-case and an existing shortcoming in flagd. Your proposal also seems solid to me. That said, I'd like to propose something similar that will, perhaps, afford a better user-experience in the end... ProposalInstead of adding a second optional arg as you've proposed, what if we change the existing implementation so that it does NOT automatically append the flag key. Essentially, this line would change to simply This would require no schema changes, and I think be a better user experience. DownsidesOf course, this would be a behaviorally breaking change in terms of the variant that will be returned give a particular bucking setup and evaluation context... however, we are still sub 1.0, and I really doubt many people are counting on assigned variants not changing with new versions, generally (though we want to be careful of this post 1.0). Additionally, we could publish some very obvious guidance for how to work around the behavioral change to retain the previous assignment (simply append the flag-key to your bucketing value manually). Also, we'd want to implement this in the in-process providers within a relatively short time frame to maintain behavioral parity. What do you think? |
In that case, the example configurations would look like this then? "targeting": {
"fractional": [
{ "cat": ["experiment-123", { "var": "user.name" }] },
[ "clubs", 25 ],
[ "diamonds", 25 ],
[ "hearts", 25 ],
[ "spades", 25 ]
]
}
"targeting": {
"fractional": [
{ "cat": [{ "var": "populationSeed": }, { "var": "user.name" }] },
[ "clubs", 25 ],
[ "diamonds", 25 ],
[ "hearts", 25 ],
[ "spades", 25 ]
]
} This was actually my first attempt at getting this to work, so that does seem more intuitive and less restrictive since any nested jsonlogic could be used here including nested ifs etc (assuming we also resolve #1265). I could imagine wild scenarios where you end up duplicating if statements twice if you for some reason want both the seed and key to be dynamic within a fractional invocation using my proposal, but I'd hope those are not the norm. I like this approach too 👍 One downside is the "base" case becomes more verbose with |
This is my main concern, but since it's a relatively advanced use case I think we can address most of the concern through good docs. I would prefer to go with this approach since it's more intuitive and avoids overloading the operation with more arguments. It would have to be marked as a breaking change but the impact would be minimal and consuming the change would be straightforward. |
The only foot gun here is that with multiple flags, users will get bucketted similarly, (ie: @colebaileygit @beeme1mr If you both agree, I think I'm comfortable suggesting that we go ahead with this implementation. @colebaileygit would you be interested in getting started on that approach? You might have issues with the e2e suite expectations not matching the new behavior, but I can help you with that if you get stuck there. I'd also be happy to update the docs accordingly. |
Sure thing! Will update the PRs above to the new approach and then look into the other memory providers that I know of |
+1 from my end. I also think this to be a good UX improvement. |
I've updated the linked PRs above, but wasn't able to quickly onboard the build / test process for What's the order of operations to get all the PRs in sync with each other and versioned? Schemas > testbed > core > providers? I especially want to make sure I'm not messing anything up with the submodules and fork branches |
I'll try and knock out the |
Given there's a breaking change (test incompatibility), you could follow this order flagd-testbed (updated tests) + new release -> flagd + new release flagd go provider should wait for flagd release as it uses the core module. The java provider can be updated independently as soon as flagd-testbed is ready with updated tests. |
Java PR is ready for review: open-feature/java-sdk-contrib#737 Small issue still needs to be resolved with the test-harness since the RPC evaluator needs to be updated once the flagd release is ready. I could also imagine moving the docker-compose helper I added out of java repo and into test-harness might make more sense here, but maybe others have a better approach. |
<!-- Please use this template for your pull request. --> <!-- Please use the sections that you need and delete other sections --> ## This PR <!-- add the description of the PR here --> - updates fractional schema to accept complex rules as first argument to override targeting so that we can support using `cat` and other rules to provide custom seeds to randomisation ### Related Issues <!-- add here the GitHub issue that this PR resolves if applicable --> open-feature/flagd#1264 resolves open-feature/flagd#1265 ### Notes <!-- any additional notes for this PR --> ### Follow-up Tasks <!-- anything that is related to this PR but not done here should be noted under this section --> <!-- if there is a need for a new issue, please link it here --> ### How to test <!-- if applicable, add testing instructions under this section --> see open-feature/flagd#1266 --------- Signed-off-by: Cole Bailey <[email protected]> Signed-off-by: Kavindu Dodanduwa <[email protected]> Co-authored-by: Kavindu Dodanduwa <[email protected]>
…nal op (#1266) <!-- Please use this template for your pull request. --> <!-- Please use the sections that you need and delete other sections --> ## This PR <!-- add the description of the PR here --> - no longer injects flagKey as seed for fractional op when user has provided custom targeting - updates schema to allow `cat` and other operations so that custom targeting can be properly seeded ### Related Issues <!-- add here the GitHub issue that this PR resolves if applicable --> #1264 ### Notes <!-- any additional notes for this PR --> ### Follow-up Tasks <!-- anything that is related to this PR but not done here should be noted under this section --> <!-- if there is a need for a new issue, please link it here --> ### How to test <!-- if applicable, add testing instructions under this section --> ```bash # unit tests make test # gherkin tests ./bin/flagd start -f file:test-harness/flags/testing-flags.json -f file:test-harness/flags/custom-ops.json -f file:test-harness/flags/evaluator-refs.json -f file:test-harness/flags/zero-flags.json make flagd-integration-test ``` --------- Signed-off-by: Cole Bailey <[email protected]> Signed-off-by: Cole Bailey <[email protected]> Signed-off-by: Kavindu Dodanduwa <[email protected]> Co-authored-by: Michael Beemer <[email protected]> Co-authored-by: Kavindu Dodanduwa <[email protected]>
@colebaileygit Updates the JS can be tracked here. |
@colebaileygit @beeme1mr I think this cane be closed with the merge of the JS implementation? Or is there something else we need as well? |
I think so! Did we need to update golang sdk with latest flagd core? |
@colebaileygit flagd go provider is already updated - https://github.com/open-feature/go-sdk-contrib/releases/tag/providers%2Fflagd%2Fv0.2.0 :) |
Requirements
Currently, the
fractional
implementation defaults to using$flagd.flagKey
as prefix for the hash key to seed the hash. This is a good default for running independent experiments across multiple feature flags at the same time.We would also like to be able to correlate multiple feature flags / systems to a single experiment, meaning the same user should be allocated to the same variant group across multiple flags and hence the same seed must be used. For this reason we would not want to use flagKey as a seed, but some unique experimentId injected into the flag targeting.
My proposal to make this possible while keeping backwards compatibility would be to allow an optional custom seed as second argument to
fractional
, e.g.:One downside to using positional arguments like this is there would be no way to provide a custom seed but also use the default
targetingKey
since the 1st argument will be interpreted as a hash key. However this has the simple workaround of explicitly giving the default value:Tasks
The text was updated successfully, but these errors were encountered: