Skip to content

xray: fix the default sampling rate for AWS X-Ray tracer#15958

Merged
asraa merged 9 commits intoenvoyproxy:mainfrom
suniltheta:awsxray_default_sampling_rate
Apr 22, 2021
Merged

xray: fix the default sampling rate for AWS X-Ray tracer#15958
asraa merged 9 commits intoenvoyproxy:mainfrom
suniltheta:awsxray_default_sampling_rate

Conversation

@suniltheta
Copy link
Copy Markdown
Contributor

Signed-off-by: Sunil Narasimhamurthy sunnrs@amazon.com

Commit Message: fix the default sampling rate for AWS X-Ray tracer extension to 5%
Additional Description:
Risk Level: Low
Testing: unit test the LocalizedSamplingStrategy to check if the default sampling rate is 0.05 if no other localized rule is applied via configuration
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

and test for the same if no localized sampling rule is applied.
Update the release ntoes with the bug fix information

Signed-off-by: Sunil Narasimhamurthy <sunnrs@amazon.com>
@suniltheta suniltheta changed the title bug: fix the default sampling rate for AWS X-Ray tracer xray: fix the default sampling rate for AWS X-Ray tracer Apr 13, 2021
/**
* @return the default manifest. Mainly for unit testing purposes.
*/
LocalizedSamplingManifest& defaultManifest() { return default_manifest_; }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since this is just used for validation in tests, can you make this a const LocalizedSamplingManifest& defaultManifest() const.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the tip. I made this change.

* tls: fix issue where OCSP was inadvertently removed from SSL response in multi-context scenarios.
* upstream: fix handling of moving endpoints between priorities when active health checks are enabled. Previously moving to a higher numbered priority was a NOOP, and moving to a lower numbered priority caused an abort.
* upstream: retry budgets will now set default values for xDS configurations.
* xray: fix the default sampling 'rate' for AWS X-Ray tracer extension to be 5%.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there a reason this is under "bug fixes" and not "minor behavioral changes"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

As per the design proposal #5644 and documented behavior, the default sampling rate for AWS X-Ray tracer is expected to be 5%. It was a typo/bug in the code that the DefaultRate value was 0.5 (50%) and not 0.05 (5%). Which will be addressed by this PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Consider appending something like "as opposed to 50%" so it's clear that was the bug.

@tonya11en
Copy link
Copy Markdown
Member

/wait-any

unit testing to be a const and add a small code comment

Signed-off-by: Sunil Narasimhamurthy <sunnrs@amazon.com>
tonya11en
tonya11en previously approved these changes Apr 14, 2021
@suniltheta
Copy link
Copy Markdown
Contributor Author

Hi @tonya11en due to the release v1.18 that went today there was a merge conflict in docs/root/version_history/current.rst file which I just resolved. Can you please review the changes again and approve? Thank you for your time.

Copy link
Copy Markdown
Member

@tonya11en tonya11en left a comment

Choose a reason for hiding this comment

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

Thanks for updating! This mostly LGTM, I just had questions/suggestions.

/wait-any

* tls: fix issue where OCSP was inadvertently removed from SSL response in multi-context scenarios.
* upstream: fix handling of moving endpoints between priorities when active health checks are enabled. Previously moving to a higher numbered priority was a NOOP, and moving to a lower numbered priority caused an abort.
* upstream: retry budgets will now set default values for xDS configurations.
* xray: fix the default sampling 'rate' for AWS X-Ray tracer extension to be 5%.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Consider appending something like "as opposed to 50%" so it's clear that was the bug.

namespace XRay {

constexpr double DefaultRate = 0.5;
// DefaultRate=0.05 corresponds to 5% sampling rate when no custom rules are applied
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: End with a period.

You also can just start with // Corresponds to....

It's not clear why only this variable gets an explanation, but the others do not. The JSON keys are obvious, but DefaultFixedTarget and SamplingFileVersion may as well get an explanation too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added the comments (explanation) for the other two variables as well. 👍

And for the previous review comment > Consider appending something like ... I made the change in the latest commit. For some reason I was not able to directly reply to that review comment.

Comment on lines +123 to +127
/**
* @return default sampling rule's sampling rate. Mainly for unit testing purposes.
*/
double defaultRuleRate() const { return default_rule_.rate(); }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this necessary? Why can't you just call defaultRule().rate()?

Copy link
Copy Markdown
Contributor Author

@suniltheta suniltheta Apr 16, 2021

Choose a reason for hiding this comment

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

From earlier suggestion in this PR, the function LocalizedSamplingStrategy::defaultManifest() function was made a const.
const LocalizedSamplingManifest& defaultManifest() const.

So the return type is a const reference of LocalizedSamplingManifest object. To make a call strategy.defaultManifest().defaultRule().rate() in the UnitTest code, the function LocalizedSamplingManifest::defaultRule() was not expected to be called by a const reference of LocalizedSamplingManifest object.

Instead of making defaultRule function as const like this ->LocalizedSamplingManifest::defaultRule const() which in turn needed multiple changes where defaultRule function is called within the source code, I opted to creating a new function double defaultRuleRate() const {} which seemed like a less code change.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you not just make a copy of the default rule in the unit test from the cost ref?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is this necessary? Why can't you just call defaultRule().rate()?

It is not necessary. In the new commit, got rid of this function (defaultRuleRate) and instead making a copy of the default_manifest_ from the const ref

Signed-off-by: Sunil Narasimhamurthy <sunnrs@amazon.com>
Sunil Narasimhamurthy added 2 commits April 16, 2021 22:43
…d make a

copy of const object for the unit testing purpose

Signed-off-by: Sunil Narasimhamurthy <sunnrs@amazon.com>
Signed-off-by: Sunil Narasimhamurthy <sunnrs@amazon.com>
tonya11en
tonya11en previously approved these changes Apr 16, 2021
Copy link
Copy Markdown
Member

@tonya11en tonya11en left a comment

Choose a reason for hiding this comment

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

Thanks! It's left in a better state than it was found, too!

LGTM assuming CI passes and all that.

@suniltheta
Copy link
Copy Markdown
Contributor Author

Once again thanks for the review and suggestions, especially the hints for making it more readable.

@suniltheta
Copy link
Copy Markdown
Contributor Author

Hi @tonya11en, I resolved a new merge conflict in docs/root/version_history/current.rst file. Can you please approve once again?
Any tip to get attention from maintainers to get this PR merged, in a nice way?

Copy link
Copy Markdown
Member

@tonya11en tonya11en left a comment

Choose a reason for hiding this comment

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

Looks like there's another conflict :(. There's a lot of churn right now in the release notes because we're setting up the new versions. Thanks for being patient.

I'll ping a maintainer once that's all fixed.

* xray: fix the default sampling 'rate' for AWS X-Ray tracer extension to be 5% as opposed to 50%.
* zipkin: fix timestamp serializaiton in annotations. A prior bug fix exposed an issue with timestamps being serialized as strings.


Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

rm extra line

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed this extra line and resolved the merge conflict.

@suniltheta suniltheta requested a review from tonya11en April 20, 2021 20:51
Signed-off-by: Sunil Narasimhamurthy <sunnrs@amazon.com>
Copy link
Copy Markdown
Member

@tonya11en tonya11en left a comment

Choose a reason for hiding this comment

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

@asraa since Matt's out of town, can another maintainer take the last pass?

@asraa
Copy link
Copy Markdown
Contributor

asraa commented Apr 21, 2021

Sure! Changes LGTM, would like to get an xray extension codeowner to check @abaptiste
But if not ping me and I will approve.

@abaptiste
Copy link
Copy Markdown
Contributor

@asraa @tonya11en LGTM

@asraa asraa merged commit 118f66e into envoyproxy:main Apr 22, 2021
@suniltheta
Copy link
Copy Markdown
Contributor Author

suniltheta commented Apr 22, 2021

thanks @abaptiste @asraa @tonya11en for your time.

gokulnair pushed a commit to gokulnair/envoy that referenced this pull request May 6, 2021
…15958)

* Fix the default sampling rate for AWS X-Ray tracer extension to 5% and test for the same if no localized sampling rule is applied. Update the release notes with the bug fix information

Signed-off-by: Sunil Narasimhamurthy <sunnrs@amazon.com>
Signed-off-by: Gokul Nair <gnair@twitter.com>
@suniltheta suniltheta deleted the awsxray_default_sampling_rate branch February 13, 2022 02:53
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