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

TracingInterceptor should take effect only one time #399

Merged
merged 2 commits into from
Mar 6, 2024
Merged

TracingInterceptor should take effect only one time #399

merged 2 commits into from
Mar 6, 2024

Conversation

wangzlei
Copy link
Contributor

@wangzlei wangzlei commented Mar 5, 2024

Issue #, if available:
It is possible for a customer to inadvertently introduce more than one X-Ray interceptor into the AWS SDK v2 client, resulting in:

  1. Generating subsegments with duplicate data, such as retry and exception. Below is the example even there is no retry, but subsegment contains retries : 1
"subsegments": [
                            {
                                "id": "529b401c23f45c01",
                                "name": "SQS",
                                "start_time": 1709320615.891,
                                "end_time": 1709320616.678,
                                "http": {
                                    "response": {
                                        "status": 200,
                                        "content_length": 106
                                    }
                                },
                                "aws": {
                                    "retries": 1,
                                    "queue_url": "https://sqs.us-east-1.amazonaws.com/133818585968/sam-dev-zgaouett-FlexMonitoringSe-ItemReactionStateChangeHandlerQue-ASj2Usx3cSJZ",
                                    "message_id": "024c4942-9515-44bf-b6c1-a08ead6f342d",
                                    "region": "us-east-1",
                                    "operation": "SendMessage",
                                    "request_id": "7d9b6cb5-fc44-50dd-be7b-32e9d7ac7162",
                                    "resource_names": [
                                        "https://sqs.us-east-1.amazonaws.com/133818585968/sam-dev-zgaouett-FlexMonitoringSe-ItemReactionStateChangeHandlerQue-ASj2Usx3cSJZ"
                                    ]
                                },
                                "namespace": "aws"
                            }
                        ]
  1. Injecting duplicate trace headers to downstream.
    Screenshot 2024-03-02 at 12 27 26 PM

Description of changes:
The PR includes 2 changes:

  1. Storing the address of the first XRay Interceptor in AWS SDK context, to make sure only one XRay Interceptor takes effect
  2. Using putHeader() instead of appendHeader() in trace header injection, this ensures the request contains only one xray trace header value.

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

@wangzlei wangzlei requested a review from a team as a code owner March 5, 2024 00:23
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 89.47368% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 28.60%. Comparing base (0cc3e14) to head (90a4734).

Files Patch % Lines
...mazonaws/xray/interceptors/TracingInterceptor.java 89.47% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #399      +/-   ##
============================================
+ Coverage     24.59%   28.60%   +4.00%     
- Complexity      505      588      +83     
============================================
  Files           138      138              
  Lines          5265     5283      +18     
  Branches        635      637       +2     
============================================
+ Hits           1295     1511     +216     
+ Misses         3786     3568     -218     
- Partials        184      204      +20     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wangzlei wangzlei changed the title only one xray TracingInterceptor should be effective TracingInterceptor should take effect only one time Mar 5, 2024
Copy link
Contributor

@vastin vastin left a comment

Choose a reason for hiding this comment

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

LGTM. ty.

@wangzlei wangzlei merged commit e1a8691 into aws:master Mar 6, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants