use of com.amazonaws.xray.strategy.sampling.SamplingRequest in project aws-xray-sdk-java by aws.
the class MatchersTest method testPartialAttributeGlobMismatch.
@Test
void testPartialAttributeGlobMismatch() {
Map<String, String> ruleAttributes = new HashMap<>();
ruleAttributes.put("ip", "127.*.0");
ruleAttributes.put("compression", "*");
Map<String, String> reqAttributes = new HashMap<>();
reqAttributes.put("ip", "127.0.0.1");
reqAttributes.put("compression", "gzip");
reqAttributes.put("encoding", "json");
SamplingRule rule = new SamplingRule().withAttributes(ruleAttributes).withHost("*").withServiceName("*").withHTTPMethod("*").withResourceARN("*").withURLPath("*").withServiceType("AWS::EC2::Instance");
SamplingRequest req = new SamplingRequest("role-arn", "arn:aws:service:us-east-1:111111111111:resource", "www.bar.com", "192.168.1.1", "GET", "/foo/baz", "AWS::EC2::Instance", reqAttributes);
Matchers m = new Matchers(rule);
Assertions.assertFalse(m.match(req));
}
use of com.amazonaws.xray.strategy.sampling.SamplingRequest in project aws-xray-sdk-java by aws.
the class MatchersTest method testSimpleMatch.
@Test
void testSimpleMatch() {
SamplingRule rule = new SamplingRule().withAttributes(null).withHost("192.168.1.1").withServiceName("www.foo.com").withHTTPMethod("POST").withResourceARN("arn:aws:service:us-east-1:111111111111:resource").withURLPath("/bar/123").withServiceType("AWS::EC2::Instance");
SamplingRequest req = new SamplingRequest("role-arn", "arn:aws:service:us-east-1:111111111111:resource", "www.foo.com", "192.168.1.1", "POST", "/bar/123", "AWS::EC2::Instance", null);
Matchers m = new Matchers(rule);
Assertions.assertTrue(m.match(req));
}
Aggregations