aws / aws/aws-xray-sdk-java

Perform out of band sampling rule polling when sampling rules are updated in the X-Ray console

Open
#82 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
100
Forks
100
PR merge metrics
No merged PRs in 30d

Description

# Background
For centralized sampling strategy (default), rule poller and target poller threads are asynchronously [spawned](https://github.com/aws/aws-xray-sdk-java/blob/master/aws-xray-recorder-sdk-core/src/main/java/com/amazonaws/xray/strategy/sampling/CentralizedSamplingStrategy.java#L55) in the background to fetch sampling rules from the X-Ray console using X-Ray daemon.
1. Rule poller makes call to [GetSamplingRules](https://github.com/aws/aws-xray-sdk-java/blob/master/aws-xray-recorder-sdk-core/src/main/java/com/amazonaws/xray/strategy/sampling/pollers/RulePoller.java#L65) X-Ray API every [5 min](https://github.com/aws/aws-xray-sdk-java/blob/master/aws-xray-recorder-sdk-core/src/main/java/com/amazonaws/xray/strategy/sampling/pollers/RulePoller.java#L27) with jitter to fetch sampling rules from the X-Ray console.
2. Target poller makes call to [GetSamplingTargets](https://github.com/aws/aws-xray-sdk-java/blob/master/aws-xray-recorder-sdk-core/src/main/java/com/amazonaws/xray/strategy/sampling/pollers/TargetPoller.java#L65) X-Ray API every [10 sec](https://github.com/aws/aws-xray-sdk-java/blob/master/aws-xray-recorder-sdk-core/src/main/java/com/amazonaws/xray/strategy/sampling/pollers/TargetPoller.java#L22) with jitter. This reports rule matched statistics within the interval to X-Ray service.

# Issue
After rule poller fetches sampling rules, if a sampling rule is created/updated/deleted, the X-Ray instrumented application will get the updated sampling rules list in the next iteration of the rule poller fetch call. In the worst case it will take 5 min for the application to start using updated list of sampling rules fetched from the X-Ray console.

# Expected Behavior
Ideally, if the sampling rules are updated from the X-Ray console, target poller should perform out of band polling of waking up rule poller to fetch updated sampling rules. In this case, the application will start using updated sampling rules in the following iteration of target poller. The worst case will be 10 seconds.

In order to do this, leverage `GetsamplingTargets` API response instance - [`GetSamplingTargetsResult`](https://github.com/aws/aws-xray-sdk-java/blob/master/aws-xray-recorder-sdk-core/src/main/java/com/amazonaws/xray/strategy/sampling/pollers/TargetPoller.java#L65). It has method `getLastRuleModification()` method that returns the last time a user changed the sampling rule configuration from the X-Ray console.

# Reference
AWS X-Ray SDK for .NET/Core has necessary logic : [code](https://github.com/aws/aws-xray-sdk-dotnet/blob/f41ad03fbec63b63a246bf76e4748c5fe346cadf/sdk/src/Core/Sampling/TargetPoller.cs#L86)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.