-
Notifications
You must be signed in to change notification settings - Fork 274
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
[Sampler.AWS] Wrapped root sampler with ParentBasedSampler #2188
base: main
Are you sure you want to change the base?
Conversation
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.
LGTM
/// <returns>an instance of <see cref="AWSXRayRemoteSampler"/>.</returns> | ||
public AWSXRayRemoteSampler Build() | ||
/// <returns>an instance of <see cref="ParentBasedSampler"/>.</returns> | ||
public ParentBasedSampler Build() |
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.
public ParentBasedSampler Build() | |
public Sampler Build() |
Shouldn't it be just Sampler
to avoid any future breaking changes?
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.
Good call. Updated the return type to be Trace.Sampler instead of ParentBasedSampler.
// This is intended for testing to check that the XRayRemoteSampler is built with the correct attributes | ||
// Should not be exposed to public as the public build method should return the sampler wrapped inside | ||
// ParentBasedSampler. | ||
internal AWSXRayRemoteSampler BuildXraySampler() |
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.
Is there a way to avoid needing a special constructor just for testing?
Could the tests call Build
, get the ParentBasedSampler
and then access the AWSXrayRemoteSampler
from that class some way?
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.
Using reflection allows us to get the private sampler in the ParentBasedSampler class. However doing so is kindoff a code smell since at this point we are relying on the internal variable naming of ParentBasedSampler and if that changes, the test breaks. I would prefer using the special constructor in this case since it's being used in the actual public facing Build function and can be used to test the AWSXrayRemoteSampler being built properly.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2188 +/- ##
===========================================
+ Coverage 73.91% 87.28% +13.36%
===========================================
Files 267 20 -247
Lines 9615 574 -9041
===========================================
- Hits 7107 501 -6606
+ Misses 2508 73 -2435
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Fixes #
Design discussion issue #
Changes
The current implementation of the X-Ray sampler has 2 levels: The X-Ray Sampler itself which is made up two different samplers for X-Ray purposes. Those two different samplers are wrapped by parentBasedSampler so that the children inherit the parent sampling decision. However, on the CloudWatch console, we are adding the children sampling decision into the stats section. This means: if we have 1 parent and 9 children, the CW console will show that 10 spans are sampled which isn't correct. It should show only 1 span being sampled. This PR moves the ParentBasedSampler wrapper to be on the root level of the X-Ray sampler. This means that the builder doesn't return AWSXrayRemoteSampler anymore but returns ParentBasedSampler(new AWSXrayRemoteSampler). This keeps the same parentBasedSampling logic but is instead on the root level thus skipping the stat aggregation for the children.
Merge requirement checklist
CHANGELOG.md
files updated for non-trivial changes