-
Notifications
You must be signed in to change notification settings - Fork 56
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
AwsXrayPropagator can create invalid trace headers during baggage propagation #563
Comments
This issue is stale because it has been open 90 days with no activity. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled |
This is still an issue, please correct, thanks! |
May I know where is the baggage from? |
Hey @wangzlei The content in the baggage is not important. In the case that triggered this for us:
Note that - my description, above, seems pretty clear about what the problem is. To re-iterate:
For us, this makes AWS XRay entirely unusable and we've had to drop it. Also, (separate from this bug), the truncation algorithm here is a little simplistic for our needs - we might want to prioritise retaining certain key-value pairs in the baggage (eg. some with specific prefixes or key values), rather than just arbitrarily dropping all baggage after a certain point. |
The X-Ray propagator seems to essentially corrupt baggage due to it's incompatibility with the W3C baggage spec. It's also quite unpredictable behaviour due to seemingly requiring to rely on the existing header length to decide where to truncate. For this reason I suggest that baggage should be ignored by the X-Ray propagator to prevent further issues. This should at least be the default behaviour. Unfortunately spec does not specify this, or anything regarding X-Ray propagator. Other implementations already do this, for example opentelemetry-js xray propagator: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/propagators/opentelemetry-propagator-aws-xray/src/AWSXRayPropagator.ts |
Thanks for providing comments. @jamesmoessis @davidconnard The reason for querying the baggage content is this issue is likely related to a feature released by Lambda in the latter half of 2023. I need to confirm once again the length of the content Lambda injects into the X-Ray trace header and whether truncating it will affect Lambda's functionality. If you can help print the the baggage introduces the issue it is helpful. |
Clarify that this issue is different than open-telemetry/opentelemetry-java-contrib#1178 |
This issue is stale because it has been open 90 days with no activity. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled |
This issue is not stale, a correction should be applied to the truncation algorithm. |
This issue is stale because it has been open 90 days with no activity. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled |
This issue is not stale, a correction should be applied to the truncation algorithm. |
Describe the bug
AwsXrayPropagator attempts to include baggage properties when creating the XRay trace header. It has code that attempts to limit the baggage to 256 characters, "as per the spec", but, that code can produce headers that are longer than 256 characters, triggering invalid requests to AWS.
see https://github.com/open-telemetry/opentelemetry-java-contrib/blob/main/aws-xray-propagator/src/main/java/io/opentelemetry/contrib/awsxray/propagator/AwsXrayPropagator.java#L130
According to https://docs.aws.amazon.com/ja_jp/step-functions/latest/apireference/API_StartExecution.html#API_StartExecution_RequestSyntax
the trace header spec appears to be 256 characters overall and not 256 characters for the remainder "baggage" bits of the header.
So, AwsXrayPropagator should take into account the entire length of the trace header (so far) when deciding whether to append (further) baggage ... and not just the length of the baggage part of it. The logic is incorrectly only looking at the additional length from baggage.
Steps to reproduce
Send requests to the AWS SDK where there is a large baggage header in the tracing context.
What did you expect to see?
The AWS SDK call should work
What did you see instead?
The AWS SDK call fails, with errors such as:
In this failed request, the baggage contents comprised of multiple properties, and the logic stopped appending when the baggage reached 244 characters. At this point, the overall header (which failed the request) was 320 characters long. So ... the truncation logic is working, but is failing to take into account the characters already in the trace header.
Additional context
This was reproduced against the SfnAsyncClient startExecutionRequest. I assume it is also reproducible against other AWS services - however, it may be that the Sfn service may be more aggressive than other services with the 256 character validation?
The text was updated successfully, but these errors were encountered: