Skip to content

Xray instrumentor for SDK V2 no longer works due to conflict in "execution.interceptors" file #2168

Closed
@MamishIo

Description

@MamishIo

Describe the bug

From https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-java.html: it should be possible to add the com.amazonaws:aws-xray-recorder-sdk-aws-sdk-v2-instrumentor dependency to automatically instrument SDK V2 clients with Xray trace information. This no longer works in newer Java SDK V2 versions due to recently added conflicting resources.

Expected Behavior

Adding dependency "aws-xray-recorder-sdk-aws-sdk-v2-instrumentor" should automatically instrument SDK clients to produce useful Xray traces.

Example screenshot from Xray service map showing tracing-enabled Lambda function calling STS, on SDK version 2.15.0:

working_2 15 0

Current Behavior

SDK clients as of 2.15.35 (and possibly earlier) are no longer instrumented automatically. Same Lambda function above no longer instruments STS call:

failing_2 15 35

Steps to Reproduce

Example repo: https://github.com/MamishIo/aws-sdk-java-v2-instrumentor-repro
Setup: mvn package to build "target/aws-sdk-java-v2-instrumentor-repro-1.0-SNAPSHOT-jar-with-dependencies.jar"

Quick repro:

  1. Open JAR as ZIP and verify that file software/amazon/awssdk/global/handlers/execution.interceptors contains only one line software.amazon.awssdk.core.internal.interceptor.HttpChecksumRequiredInterceptor.
  2. Change SDK version in POM to 2.15.0 and run mvn package again. Check same file in ZIP and verify that it now contains only one line com.amazonaws.xray.interceptors.TracingInterceptor.

Full/detailed repro:

  1. Create Lambda function (handler=io.mamish.example.LambdaHandler, tracing=active, above JAR as code package).
  2. Run with dummy Lambda test event (must be JSON string e.g. "test"). Use Xray console to verify function invocation shows but STS API call does not.
  3. Change SDK version in POM to 2.15.0 and run mvn package again. Upload JAR to function.
  4. Run Lambda function again and verify that Xray console shows function invocation and STS API calls linked together in service map.

Possible Solution

Appears to have been caused by commit 9cb352e which added file software/amazon/awssdk/global/handlers/execution.interceptors (ref) to define a new standard interceptor. This path was already being used by the instrumentor (ref) to set a global Xray interceptor but this is now being overridden by the SDK's file.

Not sure what the ideal solution is, but should be possible to work around temporarily by adding a custom execution.interceptors file containing both class names.

Improving ClasspathInterceptorChainFactory to read from multiple interceptors files could be a better long-term solution.

Context

Impact: My architecture has services invoking each other using the SDK (i.e. mainly Lambda). Automatic instrumentation made it easy to trace a request between services, but this no longer works on new SDK versions since trace information isn't propagated.

Your Environment

  • AWS Java SDK version used: Failing on 2.13.15, working on 2.13.0
  • JDK version used: default for Corretto 11 Lambda runtime
  • Operating System and version: default for Corretto 11 Lambda runtime

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions