Skip to content

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