Skip to content

AWS X-Ray Remote Sampler Part 2 - Add Rules Caching, Rules Matching Logic, Rate Limiter, and Sampling Targets Poller#4507

Closed
jj22ee wants to merge 10 commits intoopen-telemetry:mainfrom
jj22ee:xray-sampler-pr1
Closed

AWS X-Ray Remote Sampler Part 2 - Add Rules Caching, Rules Matching Logic, Rate Limiter, and Sampling Targets Poller#4507
jj22ee wants to merge 10 commits intoopen-telemetry:mainfrom
jj22ee:xray-sampler-pr1

Conversation

@jj22ee
Copy link
Copy Markdown
Contributor

@jj22ee jj22ee commented Apr 30, 2026

This PR re-opens previously approved PR #3761 that got stale and closed.

Description

Changes:

  • Add Sampling RuleCache
    • Caches a list of _SamplingRuleAppliers, ordered by rule priority then rule name. Each Rule Applier corresponds to the Sampling Rule from GetSamplingRules. Each call to GetSamplingRules will only update the Rules that have changed properties, to preserve the state of unchanged rules. This means Reservoir and Statistics will persist in Rules for unchanged rules.
    • The RuleCache will determine which Rule a set of {resource, attributes} matches with that has highest priority.
  • Added logic to fetch sampling targets for each _SamplingRuleApplier.
    • The sampling targets are periodically fetched every 10 seconds by making the GetSamplingTargets API call to X-Ray.
    • The targets determine the reservoir quota and the rate at which a _SamplingRuleApplier 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
  • Update _SamplingRuleApplier to perform Fixed Rate & Reservoir Sampling, and to include a method to apply matching logic against a set of {resource, attributes} by using the wild card and attribute matching from Utils
  • Added a _RateLimitingSampler (applied before the fixed rate sampler) to be used in each rule applier.
    • Together these samplers determine how many requests to sample every second and what percentage of additional requests to sample in that second.
  • Added class for FallbackSampler, a combination of _RateLimitingSampler and TraceIdRatioBased samplers to sample 1 req/sec and 5% of additional requests in that second.
  • Update _InternalAwsXRayRemoteSampler to depend on RuleCache and a FallbackSampler Sampler for making sampling decisions

Fixes #3305 -- This is the final PR to support X-Ray Remote Sampling.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Does This PR Require a Core Repo Change?

  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@jj22ee jj22ee requested a review from a team as a code owner April 30, 2026 02:41
@jj22ee jj22ee changed the title AWS X-Ray Remote Sampler Part 2 - Add Rules Caching, Rules Matching Logic, Rate Limiter, and Sampling Targets Poller#3761 AWS X-Ray Remote Sampler Part 2 - Add Rules Caching, Rules Matching Logic, Rate Limiter, and Sampling Targets Poller Apr 30, 2026
@jj22ee
Copy link
Copy Markdown
Contributor Author

jj22ee commented Apr 30, 2026

Actually I'll try asking to re-open previous PR: #3761
I can't re-open it myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Support for AWS X-Ray Remote Sampling

3 participants