Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for instrumenting the AWS SDK for Java V2 #56

Merged
merged 3 commits into from
Jan 30, 2019

Conversation

chrisradek
Copy link
Contributor

Issue #, if available:
#43

Description of changes:
Adds 2 new artifacts for instrumenting the AWS SDK for Java V2.

The aws-xray-recorder-sdk-aws-sdk-v2 artifact exposes a TracingInterceptor class. An instance of this class can be passed into any AWS SDK V2 service client when it is being built:

DynamoDbAsyncClient client =  DynamoDbAsyncClient.builder()
    .region(Region.US_WEST_2)
    .overrideConfiguration(ClientOverrideConfiguration.builder()
        .addExecutionInterceptor(new TracingInterceptor())
        .build()
    ).build();

The aws-xray-recorder-sdk-aws-sdk-v2-instrumentor artifact allows for easy instrumentation of all AWS SDK V2 service clients. When included as a dependency, the AWS SDK will automatically inject the TracingInterceptor into each service client.

Both artifacts will require version 2.2.0 of the aws-sdk-java artifact in order to run.

I haven't dealt with maven-managed dependencies much. Currently, neither artifact will work unless the AWS SDK V2 is also a dependency of the consuming package. This allows the customer to specify which version of the AWS SDK they wish to use. If testing shows Maven will prefer the version of an artifact that is closest to the root pom.xml (and gradle works similarly) then it might make sense to explicitly depend on the AWS SDK in the new artifacts as well.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

<groupId>software.amazon.awssdk</groupId>
<artifactId>aws-sdk-java</artifactId>
<version>2.2.0</version>
<scope>provided</scope>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked up provided on Maven official doc but not quite clear what does this mean if user application specifies aws-sdk-java-bom with newer version or older version.

@haotianw465 haotianw465 merged commit db6c2fd into aws:master Jan 30, 2019
@dmytro-bekuzarov
Copy link

If I use Java SDK v2 only, I got the following error when I try to use AWSXRayServletFilter

java.lang.NoClassDefFoundError: com/amazonaws/services/xray/model/GetSamplingRulesRequest
	at com.amazonaws.xray.strategy.sampling.pollers.RulePoller.pollRule(RulePoller.java:64)
	at com.amazonaws.xray.strategy.sampling.pollers.RulePoller.lambda$start$0(RulePoller.java:46)

According to dependency tree, the x-ray sdk relies on AWS SDK 1.x version
Can it be used using Java SDK v2 only?
P.S. I see there is a module xray under software.amazon.awssdk, what's its current status?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants