-
Notifications
You must be signed in to change notification settings - Fork 5.5k
fault: use FractionalPercent for percent #3978
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
Changes from 11 commits
35dc15a
f105661
4daaac1
4e3a07d
d4a0e76
6652866
f14d3bc
3d56b3f
f197fe2
f98bcc0
c0f9701
ca6fa14
9b1046f
aef3da0
c31bd82
f167d92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,17 +90,17 @@ class Snapshot { | |
| virtual bool featureEnabled(const std::string& key, uint64_t default_value) const PURE; | ||
|
|
||
| /** | ||
| * Test if a feature is enabled using a supplied stable random value. This variant is used if | ||
| * the caller wants a stable result over multiple calls. | ||
| * Test if a feature is enabled using the built in random generator and total number of buckets | ||
| * for sampling. | ||
| * @param key supplies the feature key to lookup. | ||
| * @param default_value supplies the default value that will be used if either the feature key | ||
| * does not exist or it is not an integer. | ||
| * @param random_value supplies the stable random value to use for determining whether the feature | ||
| * is enabled. | ||
| * @param num_buckets control max number of buckets for sampling. Sampled value will be in a range | ||
| * of [0, num_buckets). | ||
| * @return true if the feature is enabled. | ||
| */ | ||
| virtual bool featureEnabled(const std::string& key, uint64_t default_value, | ||
| uint64_t random_value) const PURE; | ||
| uint64_t num_buckets) const PURE; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. did you intend to delete this function and simply use the one below everywhere?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wanted to use the function below whenever it was possible to supply a random value. However, there are a few cases where there isn't a random number available at call time, and that's where I use this. |
||
|
|
||
| /** | ||
| * Test if a feature is enabled using a supplied stable random value and total number of buckets | ||
|
|
@@ -112,8 +112,8 @@ class Snapshot { | |
| * does not exist or it is not an integer. | ||
| * @param random_value supplies the stable random value to use for determining whether the feature | ||
| * is enabled. | ||
| * @param control max number of buckets for sampling. Sampled value will be in a range of | ||
| * [0, num_buckets). | ||
| * @param num_buckets control max number of buckets for sampling. Sampled value will be in a range | ||
| * of [0, num_buckets). | ||
| * @return true if the feature is enabled. | ||
| */ | ||
| virtual bool featureEnabled(const std::string& key, uint64_t default_value, uint64_t random_value, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -212,7 +212,7 @@ void ConnectionManagerUtility::mutateTracingRequestHeader(Http::HeaderMap& reque | |
| } | ||
|
|
||
| if (!runtime.snapshot().featureEnabled("tracing.global_enabled", | ||
| config.tracingConfig()->overall_sampling_, result)) { | ||
| config.tracingConfig()->overall_sampling_, result, 100)) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why this change?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See this comment. |
||
| UuidUtils::setTraceableUuid(x_request_id, UuidTraceStatus::NoTrace); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -146,6 +146,11 @@ std::string RandomGeneratorImpl::uuid() { | |
| return std::string(uuid, UUID_LENGTH); | ||
| } | ||
|
|
||
| bool SnapshotImpl::featureEnabled(const std::string& key, uint64_t default_value, | ||
| uint64_t num_buckets) const { | ||
| return featureEnabled(key, default_value, generator_.random(), num_buckets); | ||
| } | ||
|
|
||
| bool SnapshotImpl::featureEnabled(const std::string& key, uint64_t default_value, | ||
| uint64_t random_value, uint64_t num_buckets) const { | ||
| return random_value % num_buckets < std::min(getInteger(key, default_value), num_buckets); | ||
|
|
@@ -163,11 +168,6 @@ bool SnapshotImpl::featureEnabled(const std::string& key, uint64_t default_value | |
| } | ||
| } | ||
|
|
||
| bool SnapshotImpl::featureEnabled(const std::string& key, uint64_t default_value, | ||
| uint64_t random_value) const { | ||
| return featureEnabled(key, default_value, random_value, 100); | ||
| } | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These two functions are not equivalent.. The stable random value is not same as number of buckets above. Am I missing something here>?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| const std::string& SnapshotImpl::get(const std::string& key) const { | ||
| auto entry = values_.find(key); | ||
| if (entry == values_.end()) { | ||
|
|
||
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.
Can you do the same for aborts as well ?