Skip to content

GetSamplingTargets statistics fixes and optimizations#1274

Merged
majanjua-amzn merged 2 commits intomainfrom
gst-improvements
Jan 13, 2026
Merged

GetSamplingTargets statistics fixes and optimizations#1274
majanjua-amzn merged 2 commits intomainfrom
gst-improvements

Conversation

@majanjua-amzn
Copy link
Copy Markdown
Contributor

@majanjua-amzn majanjua-amzn commented Jan 6, 2026

Background

  1. GetSamplingTargets calls are currently inaccurate, providing statistics for the wrong rules and being called even when no stats are there.
  2. Boost statistics match the wrong rule if a rule isn't provided by an upstream service

Changes

  1. Regular Sampling: Don't call GetSamplingTargets (GST) if there are no statistics/boost statistics in the current time window, defaulting to pushing the fetch time by the default time interval
  2. Adaptive Sampling: Ensure the matchedRule is not overwritten after it has already been set to a higher priority rule

Callout

Technically, not calling GST with no statistics will cause the reservoir quota to not be up to date. However, this will only occur for an instance receiving no traffic for 10 seconds and once traffic is received the instance will call GST again within 10 seconds and get the updated quotas.

Testing

  • Added logs to each part of the sampling workflow and manually verified matching, GetSamplingTargets call behaviour (data in the request and when requests are sent)
  • Added unit test to verify GetSamplingTargets is never called when statistics are not generated (all decisions are dropped and no anomalies/boost config = no statistics generated)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@majanjua-amzn majanjua-amzn self-assigned this Jan 6, 2026
@majanjua-amzn majanjua-amzn requested a review from a team as a code owner January 6, 2026 21:50
@majanjua-amzn majanjua-amzn added enhancement New feature or request X-Ray AWS X-Ray components traces Tracing related issues java Pull requests that update Java code labels Jan 6, 2026
@majanjua-amzn majanjua-amzn merged commit 7f1beb8 into main Jan 13, 2026
15 of 21 checks passed
@majanjua-amzn majanjua-amzn deleted the gst-improvements branch January 13, 2026 18:21
majanjua-amzn added a commit that referenced this pull request Jan 15, 2026
majanjua-amzn added a commit that referenced this pull request Jan 16, 2026
X-Ray service is currently unable to receive empty statistics documents,
and we are currently investigating the response pattern to fix this. In
the meantime, we will revert the changes in this PR.

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

Labels

enhancement New feature or request java Pull requests that update Java code traces Tracing related issues X-Ray AWS X-Ray components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants