-
Notifications
You must be signed in to change notification settings - Fork 22
AWS X-Ray Remote Sampler Part 2 - Add Rules Caching and Rules Matching Logic #47
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
srprash
reviewed
Feb 9, 2024
aws-opentelemetry-distro/src/amazon/opentelemetry/distro/sampler/_rule.py
Outdated
Show resolved
Hide resolved
aws-opentelemetry-distro/src/amazon/opentelemetry/distro/sampler/_rule.py
Outdated
Show resolved
Hide resolved
aws-opentelemetry-distro/src/amazon/opentelemetry/distro/sampler/_rule.py
Outdated
Show resolved
Hide resolved
aws-opentelemetry-distro/src/amazon/opentelemetry/distro/sampler/_rule.py
Outdated
Show resolved
Hide resolved
aws-opentelemetry-distro/src/amazon/opentelemetry/distro/sampler/_rule_cache.py
Outdated
Show resolved
Hide resolved
aws-opentelemetry-distro/src/amazon/opentelemetry/distro/sampler/_rule_cache.py
Outdated
Show resolved
Hide resolved
aws-opentelemetry-distro/src/amazon/opentelemetry/distro/sampler/_rule_cache.py
Outdated
Show resolved
Hide resolved
aws-opentelemetry-distro/src/amazon/opentelemetry/distro/sampler/aws_xray_remote_sampler.py
Outdated
Show resolved
Hide resolved
2eec4d9
to
2267e09
Compare
srprash
approved these changes
Feb 13, 2024
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.
Few minor comments. Overall LGTM!
aws-opentelemetry-distro/src/amazon/opentelemetry/distro/sampler/_sampling_rule_applier.py
Show resolved
Hide resolved
aws-opentelemetry-distro/src/amazon/opentelemetry/distro/sampler/_rule.py
Outdated
Show resolved
Hide resolved
aws-opentelemetry-distro/tests/amazon/opentelemetry/distro/sampler/test_rule_cache.py
Show resolved
Hide resolved
aws-opentelemetry-distro/src/amazon/opentelemetry/distro/sampler/aws_xray_remote_sampler.py
Show resolved
Hide resolved
jj22ee
added a commit
that referenced
this pull request
Feb 16, 2024
… targets (#55) *Issue #, if available:* This is the 3rd and final part of the X-Ray Remote Sampler implementation for Python [See Part 2](#47) *Description of changes:* - Added logic to fetch sampling targets for each sampling rule applier. - The sampling targets are periodically fetched every 10 seconds by making the [GetSamplingTargets API call to X-Ray](https://docs.aws.amazon.com/xray/latest/api/API_GetSamplingTargets.html). - The targets determine the reservoir quota and the rate at which a sampling rule applier will sample the requests. - Each rule applier keeps and updates a sampling statistics document which is required in `GetSamplingTargets` call to determine the next target - Added the rate limiting and fixed rate samplers to be used in each rule applier. - Together these sampler determine how many requests to sample every second and what percentage of additional requests to sample in that second. - The FallbackSampler is a combination of above samplers to sample 1 req/sec and 5% of additional requests in that second. *Testing:* Unit Tests and Remote Sampling Testbed ## **Testbed:** 1. Have XRay Daemon running or OTel collector with XRay Proxy Client setup running. Ensure AWS credentials used has only default rule with 5% sampling and 1 req/s 2. Checkout this PR Branch, and install `pip3 install aws-opentelemetry-distro/` 3. Download this Python Sample App: https://github.com/jj22ee/aws-otel-community/tree/python-sample/centralized-sampling-tests/sample-apps/python-flask Install python3 requirements.txt Replace the following: ``` ### ### Set sampler HERE ### ``` with: ``` from amazon.opentelemetry.distro.sampler.aws_xray_remote_sampler import AwsXRayRemoteSampler xray_sampler = AwsXRayRemoteSampler(resource, polling_interval=10) trace.set_tracer_provider(TracerProvider(sampler=xray_sampler)) ``` Run Python Sample app with `python3 app.py` 4. Download this repository: https://github.com/aws-observability/aws-otel-community/ Within directory `centralized-sampling-tests/` run: `./gradlew :integration-tests:run` Check that the tests have passed. TODO: wire in the remote sampler to the ADOT Python customizer in this PR or a new PR By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue #, if available:
Second PR of 3 parts for adding the X-Ray remote sampling support for OTel Python SDK.
See Part 1
Description of changes:
RuleCache
Rule
s, ordered by rule priority then rule name. Each rule corresponds to the Sampling Rule from GetSamplingRules. Each call to GetSamplingRules will only update theRule
s that have changed properties, to preserve the state of unchanged rules. This means when Reservoir and Statistics are implemented in theRule
s, they will persist for unchanged rules.Rule
SamplingRule
and has logic to match with provided set of ResourceAttribute and SpanAttribute using theMatcher
class.Matcher
class with methods to perform:FallbackSampler
Testing:
Unit tests
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.