refactor: use http.NewRequestWithContext instead of http.NewRequest#329
Merged
oliver006 merged 3 commits intobold-commerce:masterfrom Oct 28, 2025
Merged
refactor: use http.NewRequestWithContext instead of http.NewRequest#329oliver006 merged 3 commits intobold-commerce:masterfrom
oliver006 merged 3 commits intobold-commerce:masterfrom
Conversation
…or context propagation
oliver006
previously approved these changes
Oct 28, 2025
Collaborator
oliver006
left a comment
There was a problem hiding this comment.
Looks good - thanks for the PR!
oliver006
reviewed
Oct 28, 2025
| } | ||
|
|
||
| req, err := http.NewRequest(method, u.String(), bytes.NewBuffer(js)) | ||
| req, err := http.NewRequestWithContext(ctx, method, u.String(), bytes.NewBuffer(js)) |
Collaborator
There was a problem hiding this comment.
I don't think we longer need line 237:
req = req.WithContext(ctx)
Author
There was a problem hiding this comment.
I had missed that. It also means that my "fix" is a no-op since both ways should be equivalent. My issue was probably something else then.
I will remove the line non the less.
oliver006
approved these changes
Oct 28, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I have the use case that I would like to use an OpenTelemetry instrumented http client so I can have trace information on the requests that go out to Shopify when using this client.
The current state of the library allows for the use of a custom http client, but since the request does not contain the context it leads to orphan span/traces. Using
http.NewRequestWithContextfixes that issue.