Skip to content

feat: support nested props in fractional evaluator#869

Merged
toddbaert merged 10 commits intoopen-feature:mainfrom
craigpastro:improve-fractional-evaluator
Aug 28, 2023
Merged

feat: support nested props in fractional evaluator#869
toddbaert merged 10 commits intoopen-feature:mainfrom
craigpastro:improve-fractional-evaluator

Conversation

@craigpastro
Copy link
Member

@craigpastro craigpastro commented Aug 28, 2023

This PR

This PR adds the ability to use nested properties for the bucket key in fractional evaluation. It is a breaking change from the current behaviour. If the bucket key is not provided it will default to {"cat": [{"var":"$flagd.flagKey"}, {"var":"targetingKey"}]}.

@toddbaert I am not sure that my approach to the missing bucket key is the best. I would have preferred to add {"cat": [{"var":"$flagd.flagKey"}, {"var":"targetingKey"}]} to the targeting object and let JsonLogic handle it, but it would be a bit clumsy and involve string manipulation. I don't think there is a nice way to do it, but I'll play around a bit more.

Related Issues

See #848.
Closes #843.

Notes

Follow-up Tasks

How to test

Signed-off-by: Craig Pastro <pastro.craig@gmail.com>
@netlify
Copy link

netlify bot commented Aug 28, 2023

Deploy Preview for polite-licorice-3db33c canceled.

Name Link
🔨 Latest commit eafa4f7
🔍 Latest deploy log https://app.netlify.com/sites/polite-licorice-3db33c/deploys/64ecfcbdb1837e0008e24029

@codecov
Copy link

codecov bot commented Aug 28, 2023

Codecov Report

Merging #869 (eafa4f7) into main (e007fcc) will increase coverage by 0.14%.
The diff coverage is 88.88%.

@@            Coverage Diff             @@
##             main     #869      +/-   ##
==========================================
+ Coverage   72.67%   72.81%   +0.14%     
==========================================
  Files          27       27              
  Lines        2759     2755       -4     
==========================================
+ Hits         2005     2006       +1     
+ Misses        667      664       -3     
+ Partials       87       85       -2     
Files Changed Coverage Δ
core/pkg/eval/json_evaluator.go 85.61% <ø> (ø)
core/pkg/eval/fractional_evaluation.go 72.15% <88.88%> (+4.68%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Craig Pastro added 2 commits August 28, 2023 10:45
Signed-off-by: Craig Pastro <pastro.craig@gmail.com>
Signed-off-by: Craig Pastro <pastro.craig@gmail.com>
@craigpastro craigpastro changed the title Use nested props in fractional evaluator feat: use nested props in fractional evaluator Aug 28, 2023
@craigpastro craigpastro marked this pull request as ready for review August 28, 2023 17:54
@craigpastro craigpastro requested a review from a team August 28, 2023 17:54
Signed-off-by: Craig Pastro <pastro.craig@gmail.com>
Copy link
Member

@toddbaert toddbaert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally and works as expected. Looks good to me except one small thing which I think is technically a violation of the spec, here.

Otherwise I have left some nits which I would love your input on. To reduce confusion, I've proposed bucketing property instead of target property since the latter has a bit too much overlap with targetinKey and they aren't exactly the same thing. I hope that make sense 😅

Thanks again for your help @craigpastro

Craig Pastro and others added 4 commits August 28, 2023 12:41
Co-authored-by: Todd Baert <todd.baert@dynatrace.com>
Signed-off-by: Craig Pastro <pastro.craig@gmail.com>
…l_evaluation.md

Co-authored-by: Todd Baert <todd.baert@dynatrace.com>
Signed-off-by: Craig Pastro <pastro.craig@gmail.com>
…l_evaluation.md

Co-authored-by: Todd Baert <todd.baert@dynatrace.com>
Signed-off-by: Craig Pastro <pastro.craig@gmail.com>
…l_evaluation.md

Co-authored-by: Todd Baert <todd.baert@dynatrace.com>
Signed-off-by: Craig Pastro <pastro.craig@gmail.com>
Copy link
Contributor

@Kavindu-Dodan Kavindu-Dodan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good (left a suggestion for improvement)

And I don't see this as a breaking change, so we don't have to mark the PR as a breaking change 🤔 This introduce a behavior change but that's from an invalid fractional evaluation to targetingKey as a fallback

Signed-off-by: Craig Pastro <pastro.craig@gmail.com>
@toddbaert
Copy link
Member

@craigpastro I'm really bummed but the changes seem to have broken the nice spread on your friends-character emails 😩 😩 😩

@toddbaert
Copy link
Member

Looks good (left a suggestion for improvement)

And I don't see this as a breaking change, so we don't have to mark the PR as a breaking change 🤔 This introduce a behavior change but that's from an invalid fractional evaluation to targetingKey as a fallback

Ya, using a "hard-coded" string also seems to still work. So I agree with @Kavindu-Dodan unless I'm missing something.

Signed-off-by: Craig Pastro <pastro.craig@gmail.com>
@craigpastro
Copy link
Member Author

@craigpastro I'm really bummed but the changes seem to have broken the nice spread on your friends-character emails 😩 😩 😩

LOL. No, we got it back by replacing Pheobe with Joey (and RossG with just Ross)... perhaps some deeper meaning here.

@craigpastro
Copy link
Member Author

Looks good (left a suggestion for improvement)
And I don't see this as a breaking change, so we don't have to mark the PR as a breaking change 🤔 This introduce a behavior change but that's from an invalid fractional evaluation to targetingKey as a fallback

Ya, using a "hard-coded" string also seems to still work. So I agree with @Kavindu-Dodan unless I'm missing something.

Oh, yes, this is true. It will no longer extract the value of that hardcoded string from the context though.

@craigpastro
Copy link
Member Author

Thanks again for your help @craigpastro

It's my pleasure! Will definitely look for other opportunities to contribute in the future.

@toddbaert
Copy link
Member

I'm going to merge this, but cc'ing @bacherfl . Hoping to put this out in a release soon now that #843 seems complete. Let me know if you have concerns.

@toddbaert toddbaert changed the title feat: use nested props in fractional evaluator feat: support nested props in fractional evaluator Aug 28, 2023
@toddbaert toddbaert merged commit 50ff739 into open-feature:main Aug 28, 2023
@github-actions github-actions bot mentioned this pull request Aug 28, 2023
@craigpastro craigpastro deleted the improve-fractional-evaluator branch August 28, 2023 21:52
beeme1mr pushed a commit that referenced this pull request Aug 31, 2023
🤖 I have created a release *beep* *boop*
---


<details><summary>flagd: 0.6.4</summary>

##
[0.6.4](flagd/v0.6.3...flagd/v0.6.4)
(2023-08-30)


### 🐛 Bug Fixes

* **deps:** update module github.com/cucumber/godog to v0.13.0
([#855](#855))
([5b42486](5b42486))
* **deps:** update module github.com/open-feature/flagd/core to v0.6.3
([#794](#794))
([9671964](9671964))


### 🧹 Chore

* **deps:** update golang docker tag to v1.21
([#822](#822))
([effe29d](effe29d))
</details>

<details><summary>flagd-proxy: 0.2.9</summary>

##
[0.2.9](flagd-proxy/v0.2.8...flagd-proxy/v0.2.9)
(2023-08-30)


### 🐛 Bug Fixes

* **deps:** update module github.com/open-feature/flagd/core to v0.6.3
([#794](#794))
([9671964](9671964))


### 🧹 Chore

* **deps:** update golang docker tag to v1.21
([#822](#822))
([effe29d](effe29d))
</details>

<details><summary>core: 0.6.4</summary>

##
[0.6.4](core/v0.6.3...core/v0.6.4)
(2023-08-30)


### 🐛 Bug Fixes

* **deps:** update kubernetes packages to v0.28.0
([#841](#841))
([cc195e1](cc195e1))
* **deps:** update kubernetes packages to v0.28.1
([#860](#860))
([f3237c2](f3237c2))
* **deps:** update module github.com/open-feature/open-feature-operator
to v0.2.36 ([#799](#799))
([fa4da4b](fa4da4b))
* **deps:** update module golang.org/x/crypto to v0.12.0
([#797](#797))
([edae3fd](edae3fd))
* **deps:** update module golang.org/x/net to v0.14.0
([#798](#798))
([92c2f26](92c2f26))
* **deps:** update module sigs.k8s.io/controller-runtime to v0.15.1
([#795](#795))
([13d62fd](13d62fd))
* **deps:** update module sigs.k8s.io/controller-runtime to v0.16.0
([#856](#856))
([88d832a](88d832a))


### ✨ New Features

* add flag key to hash in fractional evaluation
([#847](#847))
([ca6a35f](ca6a35f))
* add gRPC healthchecks
([#863](#863))
([da30b7b](da30b7b))
* support nested props in fractional evaluator
([#869](#869))
([50ff739](50ff739))


### 🧹 Chore

* deprecate fractionalEvaluation for fractional
([#873](#873))
([243fef9](243fef9))
* replace xxh3 with murmur3 in bucket algorithm
([#846](#846))
([c3c9e4e](c3c9e4e))
</details>

---
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>
@github-actions github-actions bot mentioned this pull request Dec 2, 2023
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.

Improvements to fractional custom evalutor

3 participants