in aws-xray-recorder-sdk-core/src/main/java/com/amazonaws/xray/strategy/sampling/LocalizedSamplingStrategy.java [120:154]
private static List<SamplingRule> processRuleManifest(SamplingRuleManifest manifest) {
SamplingRule defaultRule = manifest.getDefaultRule();
if (!SUPPORTED_VERSIONS.contains(manifest.getVersion())) {
throw newInvalidSamplingRuleManifestException("Manifest version: " + manifest.getVersion() + " is not supported.");
}
if (defaultRule != null) {
if (defaultRule.getUrlPath() != null || defaultRule.getHost() != null || defaultRule.getHttpMethod() != null) {
throw newInvalidSamplingRuleManifestException(
"The default rule must not specify values for url_path, host, or http_method.");
} else if (defaultRule.getFixedTarget() < 0 || defaultRule.getRate() < 0) {
throw newInvalidSamplingRuleManifestException(
"The default rule must specify non-negative values for fixed_target and rate.");
}
List<SamplingRule> rules = manifest.getRules();
if (rules != null) {
for (SamplingRule rule : rules) {
if (manifest.getVersion() == 1) {
rule.setHost(rule.getServiceName());
}
if (rule.getUrlPath() == null || rule.getHost() == null || rule.getHttpMethod() == null) {
throw newInvalidSamplingRuleManifestException(
"All rules must have values for url_path, host, and http_method.");
} else if (rule.getFixedTarget() < 0 || rule.getRate() < 0) {
throw newInvalidSamplingRuleManifestException(
"All rules must have non-negative values for fixed_target and rate.");
}
}
return rules;
} else {
return new ArrayList<>();
}
} else {
throw newInvalidSamplingRuleManifestException("A default rule must be provided.");
}
}