in aws-xray-recorder-sdk-core/src/main/java/com/amazonaws/xray/strategy/sampling/rule/Matchers.java [48:73]
boolean match(SamplingRequest req) {
// Comparing against the full list of matchers can be expensive. We try to short-circuit the req as quickly
// as possible by comparing against matchers with high variance and moving down to matchers that are almost
// always "*".
Map<String, String> requestAttributes = req.getAttributes();
// Ensure that each defined attribute in the sampling rule is satisfied by the request. It is okay for the
// request to have attributes with no corresponding match in the sampling rule.
for (Map.Entry<String, String> a : attributes.entrySet()) {
if (!requestAttributes.containsKey(a.getKey())) {
return false;
}
if (!SearchPattern.wildcardMatch(a.getValue(), requestAttributes.get(a.getKey()))) {
return false;
}
}
// Missing string parameters from the sampling request are replaced with ""s to ensure they match against *
// matchers.
return SearchPattern.wildcardMatch(url, req.getUrl().orElse(""))
&& SearchPattern.wildcardMatch(service, req.getService().orElse(""))
&& SearchPattern.wildcardMatch(method, req.getMethod().orElse(""))
&& SearchPattern.wildcardMatch(host, req.getHost().orElse(""))
&& SearchPattern.wildcardMatch(serviceType, req.getServiceType().orElse(""));
}