Skip to content
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

Experience sampling weight #80

Merged
merged 5 commits into from
Jun 11, 2018

Conversation

jmileham
Copy link
Member

@jmileham jmileham commented Jun 6, 2018

Summary

Add an EXPERIENCE_SAMPLING_WEIGHT env var and a new v2 split_registry endpoint to expose its value to clients.

The idea here is to tell clients to probablistically sample FeatureGateExperienced events at a given sampling weight. Sampling weight is the reciprocal of sample fraction, i.e. a sampling weight of 10 means that one in ten experience events should be reported to the analytics server and hence each sampled event represents ten real-world experiences.

This is a data volume reduction/cost saving measure. The default value is 1, meaning every experience event should be reported. The value 0 is intended to disable all experience events. This relies on the client reading the new split registry endpoint and sampling appropriately.

In order to make this feature work, I had to change the structure of the split_registries endpoint because it didn't have enough flexibility in it. It used to be just a JSON object with keys representing splits. I added a wrapper object and dropped the previous object into a splits key. That created space for a experience_sampling_weight key.

While I was in there, I actually added more flex to the way split weightings are expressed: there's a similar issue there where the value of a given split was previously just a set of weightings. This means we can't transmit metadata abouta split other than weights in the v1 format. So I'm auditioning an expansion that puts the weightings in a weights key and allows us to add things like a feature_gate boolean to the payload.

This will add significant verbosity to the page. I'm not sure it's worth it, but it would've allowed me to stop having clients heuristically decide whether a given split is a feature gate or not based on suffix in the last iteration. Thoughts? I can pull that commit out of this PR if we don't want to go there.

/domain @Betterment/test_track_core
/platform @aburgel @samandmoore

@nanda-prbot
Copy link

Needs somebody from @Betterment/test_track_core to claim domain review
Needs somebody from @aburgel and @samandmoore to claim platform review

Use the shovel operator to claim, e.g.:

@myname << domain && platform

json.feature_gate split.feature_gate?
end
end
json.merge!({})
Copy link
Member Author

Choose a reason for hiding this comment

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

This seems a little ugly but it was the only way I found to force the splits key to appear with an empty object as a value. If the loop is empty, otherwise the split key disappears entirely. Is there a more revealing approach?

@split_registry.splits.each do |split|
json.set! split.name do
json.weights split.registry
json.feature_gate split.feature_gate?
Copy link
Member Author

Choose a reason for hiding this comment

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

Another advantage of this representation would be that we could theoretically set different sample rates for different splits if e.g. different apps were running at different orders of magnitude of scale.

@jmileham jmileham force-pushed the experience_sampling_weight branch from 7c04ddc to b16a4ba Compare June 6, 2018 19:31
@jmileham jmileham force-pushed the experience_sampling_weight branch from b16a4ba to a2145bd Compare June 7, 2018 20:53
@aburgel
Copy link
Collaborator

aburgel commented Jun 8, 2018

I'm in favor of the new split registry format, it should compress well since there are so many repeated strings, so the actual payload size might not change significantly.

This all looks great! << domainlgtm

@samandmoore can you take the other review?

@nanda-prbot
Copy link

Needs somebody from @aburgel and @samandmoore to claim platform review

Use the shovel operator to claim, e.g.:

@myname << domain && platform

@samandmoore
Copy link
Member

samandmoore commented Jun 8, 2018 via email

@nanda-prbot
Copy link

Needs somebody from @aburgel and @samandmoore to claim platform review

Use the shovel operator to claim, e.g.:

@myname << domain && platform

end

it "returns 1 with no env var" do
with_env EXPERIENCE_SAMPLININGG_WEIGHT: nil do
Copy link
Member Author

Choose a reason for hiding this comment

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

Typo

@samandmoore
Copy link
Member

<<platform

@nanda-prbot
Copy link

Needs @samandmoore to provide platform review

When you finish a round of review, be sure to say you've finished or sign off on the PR, e.g.:

TAFN or DomainLGTM

If you're too busy to review, unclaim the PR, e.g.:

@myname >> domain

Copy link
Member

@samandmoore samandmoore 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! Just fix that typo.

@samandmoore
Copy link
Member

platformlgtm

@nanda-prbot
Copy link

Approved! 🔩 ⚡ 💫

@jmileham
Copy link
Member Author

Only downside to the compressibility is that presently when we pass the registry through to the JS client in the HTML payload we base64 it first, which will lose all the compressibility. I think the next gen answer here will probably involve GZipping the content before base64ing it or something.

@jmileham jmileham merged commit 5098de6 into Betterment:master Jun 11, 2018
@jmileham jmileham deleted the experience_sampling_weight branch June 11, 2018 16:49
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.

4 participants