Skip to content

Conversation

@malcolmrebughini
Copy link

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.NewRequestWithContext fixes that issue.

oliver006
oliver006 previously approved these changes Oct 28, 2025
Copy link
Collaborator

@oliver006 oliver006 left a comment

Choose a reason for hiding this comment

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

Looks good - thanks for the PR!

Copy link
Collaborator

@oliver006 oliver006 left a comment

Choose a reason for hiding this comment

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

one small thing

}

req, err := http.NewRequest(method, u.String(), bytes.NewBuffer(js))
req, err := http.NewRequestWithContext(ctx, method, u.String(), bytes.NewBuffer(js))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we longer need line 237:

req = req.WithContext(ctx)

Copy link
Author

@malcolmrebughini malcolmrebughini Oct 28, 2025

Choose a reason for hiding this comment

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

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 oliver006 merged commit d6ea15a into bold-commerce:master Oct 28, 2025
3 checks passed
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