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

[Fix] Update AWS SDK Instrumentation to inject XRay trace context into HTTP Headers #132

Closed
wants to merge 1 commit into from

Conversation

jj22ee
Copy link
Contributor

@jj22ee jj22ee commented Dec 13, 2024

Issue #, if available:
Fixes the absence of broken X-Ray context propagation when the underlying HTTP instrumentation is suppressed or disabled.

Similarly to Java and Python, AWS SDK itself can inject the X-Ray Context into the HTTP Headers:

Note - If the underlying HTTP instrumentation is enabled, then the underlying HTTP Child Span of the AWS SDK Span will overwrite the Trace Context to propagate through headers.

Description of changes:

  • Move patched/extended instrumentations to an patches/extended-instrumentations/ directory
  • Created AwsSdkInstrumentationExtended class that extends upstream AwsInstrumentation to add an additional instrumentation. The additional instrumentation will modify the HttpRequest class with an updated constructor to inject the X-Amzn-Trace-Id HTTP header.
    • Uses propwrap.ts that is taken from upstream OTel.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

(moduleExports: any) => {
const newExports = propwrap(moduleExports, 'HttpRequest', (origHttpRequest: any) => {
class ExtendedHttpRequest extends origHttpRequest {
constructor(...args: any[]) {
Copy link
Member

Choose a reason for hiding this comment

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

I like the other option than this one. The other is more cohesive to the send method itself and middleware is the right tool to modify the request from my view. :)

@jj22ee jj22ee closed this Dec 16, 2024
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.

2 participants