diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5885810e..54b56ff6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# Change Log
+## 2.0.1 - 2018-09-06
+### Changed
+- Fixed a bug that caused XRay sampling rules fetching to fail when AWS SDK instrumentor is included. [ISSUE25](https://github.com/aws/aws-xray-sdk-java/issues/25)
+
## 2.0.0 - 2018-08-28
### Backwards incompatible change
- Default Sampling Strategy has been updated to Centralized Sampling Strategy which gets sampling rules from X-Ray backend instead of from a static JSON file. [More Information](https://docs.aws.amazon.com/xray/latest/devguide/xray-console-sampling.html)
@@ -28,7 +32,7 @@
## 1.2.2 - 2017-12-05
### Changed
-- Fixed a bug a bug which caused certain non-sampled segments to be emitted to the X-Ray daemon. This issue occurred only when the segment began as sampled and was manually overridden to non-sampled using `setSampled(false)`.
+- Fixed a bug which caused certain non-sampled segments to be emitted to the X-Ray daemon. This issue occurred only when the segment began as sampled and was manually overridden to non-sampled using `setSampled(false)`.
## 1.2.1 - 2017-11-20
### Changed
diff --git a/README.md b/README.md
index cd299ad9..cb9be179 100644
--- a/README.md
+++ b/README.md
@@ -14,37 +14,37 @@ Add the AWS X-Ray SDK dependencies to your pom.xml:
com.amazonaws
aws-xray-recorder-sdk-core
- 2.0.0
+ 2.0.1
com.amazonaws
aws-xray-recorder-sdk-apache-http
- 2.0.0
+ 2.0.1
com.amazonaws
aws-xray-recorder-sdk-aws-sdk
- 2.0.0
+ 2.0.1
com.amazonaws
aws-xray-recorder-sdk-aws-sdk-instrumentor
- 2.0.0
+ 2.0.1
com.amazonaws
aws-xray-recorder-sdk-sql-mysql
- 2.0.0
+ 2.0.1
com.amazonaws
aws-xray-recorder-sdk-sql-postgresql
- 2.0.0
+ 2.0.1
com.amazonaws
aws-xray-recorder-sdk-spring
- 2.0.0
+ 2.0.1
```
diff --git a/aws-xray-recorder-sdk-apache-http/pom.xml b/aws-xray-recorder-sdk-apache-http/pom.xml
index 0a2d8157..c289bc6f 100644
--- a/aws-xray-recorder-sdk-apache-http/pom.xml
+++ b/aws-xray-recorder-sdk-apache-http/pom.xml
@@ -4,11 +4,11 @@
com.amazonaws
aws-xray-recorder-sdk-pom
- 2.0.0
+ 2.0.1
com.amazonaws
aws-xray-recorder-sdk-apache-http
- 2.0.0
+ 2.0.1
AWS X-Ray Recorder SDK for Java - Apache HTTP Client Proxy
diff --git a/aws-xray-recorder-sdk-aws-sdk-instrumentor/pom.xml b/aws-xray-recorder-sdk-aws-sdk-instrumentor/pom.xml
index 6f386299..9d90a094 100644
--- a/aws-xray-recorder-sdk-aws-sdk-instrumentor/pom.xml
+++ b/aws-xray-recorder-sdk-aws-sdk-instrumentor/pom.xml
@@ -4,11 +4,11 @@
com.amazonaws
aws-xray-recorder-sdk-pom
- 2.0.0
+ 2.0.1
com.amazonaws
aws-xray-recorder-sdk-aws-sdk-instrumentor
- 2.0.0
+ 2.0.1
AWS X-Ray Recorder SDK for Java - AWS SDK Instrumentor
diff --git a/aws-xray-recorder-sdk-aws-sdk/pom.xml b/aws-xray-recorder-sdk-aws-sdk/pom.xml
index 066f6f68..a386c9b9 100644
--- a/aws-xray-recorder-sdk-aws-sdk/pom.xml
+++ b/aws-xray-recorder-sdk-aws-sdk/pom.xml
@@ -4,11 +4,11 @@
com.amazonaws
aws-xray-recorder-sdk-pom
- 2.0.0
+ 2.0.1
com.amazonaws
aws-xray-recorder-sdk-aws-sdk
- 2.0.0
+ 2.0.1
AWS X-Ray Recorder SDK for Java - AWS SDK Handler
diff --git a/aws-xray-recorder-sdk-aws-sdk/src/main/java/com/amazonaws/xray/handlers/TracingHandler.java b/aws-xray-recorder-sdk-aws-sdk/src/main/java/com/amazonaws/xray/handlers/TracingHandler.java
index a0d40a74..5a2f9cc5 100644
--- a/aws-xray-recorder-sdk-aws-sdk/src/main/java/com/amazonaws/xray/handlers/TracingHandler.java
+++ b/aws-xray-recorder-sdk-aws-sdk/src/main/java/com/amazonaws/xray/handlers/TracingHandler.java
@@ -58,6 +58,10 @@ public class TracingHandler extends RequestHandler2 {
private static final String S3_EXTENDED_REQUEST_ID_HEADER_KEY = "x-amz-id-2";
private static final String CONTENT_LENGTH_HEADER_KEY = "Content-Length";
+ private static final String XRAY_SERVICE_NAME = "AWSXRay";
+ private static final String XRAY_SAMPLING_RULE_REQUEST = "GetSamplingRules";
+ private static final String XRAY_SAMPLING_TARGET_REQUEST = "GetSamplingTargets";
+
private static final String REQUEST_ID_SUBSEGMENT_KEY = "request_id";
private static final String EXTENDED_REQUEST_ID_SUBSEGMENT_KEY = "id_2";
private static final String CONTENT_LENGTH_SUBSEGMENT_KEY = "content_length";
@@ -138,7 +142,15 @@ public AmazonWebServiceRequest beforeExecution(AmazonWebServiceRequest request)
@Override
public void beforeRequest(Request> request) {
- if(S3_SERVICE_NAME.equals(extractServiceName(request)) && S3_PRESIGN_REQUEST.equals(extractOperationName(request))) {
+ String serviceName = extractServiceName(request);
+ String operationName = extractOperationName(request);
+
+ if(S3_SERVICE_NAME.equals(serviceName) && S3_PRESIGN_REQUEST.equals(operationName)) {
+ return;
+ }
+
+ if(XRAY_SERVICE_NAME.equals(serviceName) && (XRAY_SAMPLING_RULE_REQUEST.equals(operationName)
+ || XRAY_SAMPLING_TARGET_REQUEST.equals(operationName))) {
return;
}
@@ -149,12 +161,12 @@ public void beforeRequest(Request> request) {
if (null != entityContext) {
recorder.setTraceEntity(entityContext);
}
- Subsegment currentSubsegment = recorder.beginSubsegment(extractServiceName(request));
+ Subsegment currentSubsegment = recorder.beginSubsegment(serviceName);
if (null == currentSubsegment) {
return;
}
currentSubsegment.putAllAws(extractRequestParameters(request));
- currentSubsegment.putAws(OPERATION_SUBSEGMENT_KEY, extractOperationName(request));
+ currentSubsegment.putAws(OPERATION_SUBSEGMENT_KEY, operationName);
if (null != accountId) {
currentSubsegment.putAws(ACCOUNT_ID_SUBSEGMENT_KEY, accountId);
}
diff --git a/aws-xray-recorder-sdk-aws-sdk/src/test/java/com/amazonaws/xray/handlers/TracingHandlerTest.java b/aws-xray-recorder-sdk-aws-sdk/src/test/java/com/amazonaws/xray/handlers/TracingHandlerTest.java
index 58d93fb9..3c306c13 100644
--- a/aws-xray-recorder-sdk-aws-sdk/src/test/java/com/amazonaws/xray/handlers/TracingHandlerTest.java
+++ b/aws-xray-recorder-sdk-aws-sdk/src/test/java/com/amazonaws/xray/handlers/TracingHandlerTest.java
@@ -5,6 +5,9 @@
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
+import com.amazonaws.services.xray.AWSXRayClientBuilder;
+import com.amazonaws.services.xray.model.GetSamplingRulesRequest;
+import com.amazonaws.services.xray.model.GetSamplingTargetsRequest;
import org.apache.http.HttpResponse;
import org.apache.http.HttpVersion;
import org.apache.http.client.methods.HttpUriRequest;
@@ -84,12 +87,9 @@ public void testLambdaInvokeSubsegmentContainsFunctionName() {
InvokeRequest request = new InvokeRequest();
request.setFunctionName("testFunctionName");
InvokeResult r = lambda.invoke(request);
- System.out.println(r.getStatusCode());
- System.out.println(r);
Assert.assertEquals(1, segment.getSubsegments().size());
Assert.assertEquals("Invoke", segment.getSubsegments().get(0).getAws().get("operation"));
- System.out.println(segment.getSubsegments().get(0).getAws());
Assert.assertEquals("testFunctionName", segment.getSubsegments().get(0).getAws().get("function_name"));
}
@@ -105,7 +105,6 @@ public void testS3PutObjectSubsegmentContainsBucketName() {
s3.putObject(BUCKET, KEY, "This is a test from java");
Assert.assertEquals(1, segment.getSubsegments().size());
Assert.assertEquals("PutObject", segment.getSubsegments().get(0).getAws().get("operation"));
- System.out.println(segment.getSubsegments().get(0).getAws());
Assert.assertEquals(BUCKET, segment.getSubsegments().get(0).getAws().get("bucket_name"));
Assert.assertEquals(KEY, segment.getSubsegments().get(0).getAws().get("key"));
}
@@ -126,11 +125,26 @@ public void testS3CopyObjectSubsegmentContainsBucketName() {
s3.copyObject(BUCKET, KEY, DST_BUCKET, DST_KEY);
Assert.assertEquals(1, segment.getSubsegments().size());
Assert.assertEquals("CopyObject", segment.getSubsegments().get(0).getAws().get("operation"));
- System.out.println(segment.getSubsegments().get(0).getAws());
Assert.assertEquals(BUCKET, segment.getSubsegments().get(0).getAws().get("source_bucket_name"));
Assert.assertEquals(KEY, segment.getSubsegments().get(0).getAws().get("source_key"));
Assert.assertEquals(DST_BUCKET, segment.getSubsegments().get(0).getAws().get("destination_bucket_name"));
Assert.assertEquals(DST_KEY, segment.getSubsegments().get(0).getAws().get("destination_key"));
}
+ @Test
+ public void testShouldNotTraceXRaySamplingOperations() {
+ com.amazonaws.services.xray.AWSXRay xray = AWSXRayClientBuilder.standard()
+ .withRequestHandlers(new TracingHandler()).withRegion(Regions.US_EAST_1)
+ .withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("fake", "fake")))
+ .build();
+ mockHttpClient(xray, null);
+
+ Segment segment = AWSXRay.beginSegment("test");
+ xray.getSamplingRules(new GetSamplingRulesRequest());
+ Assert.assertEquals(0, segment.getSubsegments().size());
+
+ xray.getSamplingTargets(new GetSamplingTargetsRequest());
+ Assert.assertEquals(0, segment.getSubsegments().size());
+ }
+
}
diff --git a/aws-xray-recorder-sdk-bom/pom.xml b/aws-xray-recorder-sdk-bom/pom.xml
index 15a8c18e..14ee67bb 100644
--- a/aws-xray-recorder-sdk-bom/pom.xml
+++ b/aws-xray-recorder-sdk-bom/pom.xml
@@ -4,7 +4,7 @@
com.amazonaws
aws-xray-recorder-sdk-pom
- 2.0.0
+ 2.0.1
com.amazonaws
aws-xray-recorder-sdk-bom
diff --git a/aws-xray-recorder-sdk-core/pom.xml b/aws-xray-recorder-sdk-core/pom.xml
index 4b3c5957..77128ee3 100644
--- a/aws-xray-recorder-sdk-core/pom.xml
+++ b/aws-xray-recorder-sdk-core/pom.xml
@@ -4,12 +4,12 @@
com.amazonaws
aws-xray-recorder-sdk-pom
- 2.0.0
+ 2.0.1
com.amazonaws
aws-xray-recorder-sdk-core
AWS X-Ray Recorder SDK for Java - Core
- 2.0.0
+ 2.0.1
diff --git a/aws-xray-recorder-sdk-spring/pom.xml b/aws-xray-recorder-sdk-spring/pom.xml
index dc8f8105..8d03267e 100644
--- a/aws-xray-recorder-sdk-spring/pom.xml
+++ b/aws-xray-recorder-sdk-spring/pom.xml
@@ -5,7 +5,7 @@
com.amazonaws
aws-xray-recorder-sdk-pom
- 2.0.0
+ 2.0.1
aws-xray-recorder-sdk-spring
diff --git a/aws-xray-recorder-sdk-sql-mysql/pom.xml b/aws-xray-recorder-sdk-sql-mysql/pom.xml
index cb689e73..5ac58668 100644
--- a/aws-xray-recorder-sdk-sql-mysql/pom.xml
+++ b/aws-xray-recorder-sdk-sql-mysql/pom.xml
@@ -4,11 +4,11 @@
com.amazonaws
aws-xray-recorder-sdk-pom
- 2.0.0
+ 2.0.1
com.amazonaws
aws-xray-recorder-sdk-sql-mysql
- 2.0.0
+ 2.0.1
AWS X-Ray Recorder SDK for Java - AWS SDK MySQL Interceptor
diff --git a/aws-xray-recorder-sdk-sql-postgres/pom.xml b/aws-xray-recorder-sdk-sql-postgres/pom.xml
index 6d199ff7..61fa15b1 100644
--- a/aws-xray-recorder-sdk-sql-postgres/pom.xml
+++ b/aws-xray-recorder-sdk-sql-postgres/pom.xml
@@ -5,11 +5,11 @@
com.amazonaws
aws-xray-recorder-sdk-pom
- 2.0.0
+ 2.0.1
com.amazonaws
aws-xray-recorder-sdk-sql-postgres
- 2.0.0
+ 2.0.1
AWS X-Ray Recorder SDK for Java - AWS SDK PostgreSQL Interceptor
diff --git a/aws-xray-recorder-sdk/pom.xml b/aws-xray-recorder-sdk/pom.xml
index 4e528cad..ecb4828f 100644
--- a/aws-xray-recorder-sdk/pom.xml
+++ b/aws-xray-recorder-sdk/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.amazonaws
aws-xray-recorder-sdk
- 2.0.0
+ 2.0.1
@@ -45,7 +45,7 @@
com.amazonaws
aws-xray-recorder-sdk-bom
- 2.0.0
+ 2.0.1
pom
import
diff --git a/pom.xml b/pom.xml
index f370c328..e3bc135e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.amazonaws
aws-xray-recorder-sdk-pom
- 2.0.0
+ 2.0.1
pom
AWS X-Ray Recorder SDK for Java
The Amazon Web Services X-Ray Recorder SDK for Java provides Java APIs for emitting tracing data to AWS X-Ray. AWS X-Ray helps developers analyze and debug distributed applications. With X-Ray, you can understand how your application and its underlying services are performing to identify and troubleshoot the root cause of performance issues and errors.
@@ -46,7 +46,7 @@
- 2.0.0
+ 2.0.1
UTF-8