aws / aws/aws-xray-sdk-node

[fetch] does not support fetch options like proxy

Open
#650 10 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
280
Forks
157
PR merge metrics
No merged PRs in 30d

Description

When using the `aws-xray-sdk-fetch` instrumentation it is not possible to supply further options to the fetch call like the agent to supply the undici ProxyAgent.

The `capturedFetch` call only calls the global available fetch call with one argument https://github.com/aws/aws-xray-sdk-node/blob/73e1fcaba509a6b6fcfc81254a25da37189bea4b/sdk_contrib/fetch/lib/fetch_p.js#L117 and does not pass down options provided by the user.

I would propose to add a third option to the function that patches the global fetch. This would allow the user to use all fetch options and additionally supply their own segment information if required.
https://github.com/aws/aws-xray-sdk-node/blob/73e1fcaba509a6b6fcfc81254a25da37189bea4b/sdk_contrib/fetch/lib/fetch_p.js#L59

For this change it would be necessary to think about how not to introduce a breaking change for users that expect the second argument to be used for segment information. But I guess we can write some internal logic to check the supplied args.

Once I receive some feedback I can get started on a PR and implement the changes.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.