You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AWS X-Ray Remote Sampler Part 3 - rate limiter logic and get sampling 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.
0 commit comments